How we can use current time instead of '15:33:56' now() Function or time() but it gives wrong time in AM and PM.

<?php


function twentyfourToTwelve($time)
{
    return date('g:i:sa', strtotime($time));
}


 /*** Example usage ***/
 echo twentyfourToTwelve('15:33:56').'<br />';

 echo twentyfourToTwelve('15:33').'<br />';

 echo twentyfourToTwelve('15.12').'<br />';

 echo twentyfourToTwelve('2:33:56').'<br />';

 echo twentyfourToTwelve('15:33').'<br />';
?>
function twentyfourToTwelve($time)
{
    return date('g:i:s a', strtotime($time . " UTC"));
}
 
 
 /*** Example usage ***/
 echo twentyfourToTwelve('15:33:56');

This work?

This show 8:33:56 pm in result.
Its wrong.
I need to show time in my website in 12 Hours Format so please tell me.

Congrats adatapost
i want to show time on my website .
pakistan standard time with 12 hours time.
please tell me how to.

For **** sakes Ayesha, if you'd said you wanted Pakistan time, that would have been straight forward - we ain't got no crystal balls you know. Look at the php documentation on setting times. Sheesh...

This question has already been answered. Start a new discussion instead.