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 />';
?>