Where does that string come from? You can have time automatically displayed and formatted any way you want, you know that? If it is a text string, here is a poor excuse for a workaround using 'explode()':
<?php
$time = explode(":", $string); // *1
$hour = $time[0];
$minute = $time[1];
$second = $time[2];
if ($hour=='0') || ($hour=='00')
{$hour='12'; $ampm='am';} // 2
elseif ($hour=='12')
{$ampm='pm';} // 3
endif;
if ($hour > 12)
{$hour=$hour-=12; $ampm='pm';} // 4
else {$ampm='am';} // 5
print "$hour:$minute $ampm";
?>
Comments:
1 // use ":" as the separator. $var now is an array containing 3 elements: (20,45,00). Each element is assigned a variable with an obvious name.
2 // if $hour='0' or '00', it's morning.
3 // if $hour='12', it's some time after noon.
4 // if $hour is greater than 12, subtract 12 hours and make it "pm".
*4 // if $hour is less than 12 ("equal" has been ruled out before), no need to change the value of $hours. Just make it "am".
I'm a newbie too and I didn't test the code, so watch out for possible mistakes.
HTH,
Luciano ES
Santos - SP - Brasil