Hello:
Can someone please tell me if it is possible to convert the time like listed below?
19:30:00 = 7:30 PM
19:30:00
7:30 PM
Anythng close to being like that would be great as well.
Thanks
there are a couple of ways you can do it using a combination of functions in the date/time section of the manual.... or if you just need something quick,
$temp=explode(":",$currtime); if($temp[0]>12){ $temp[0]=$temp[0]-12; $temp[2]=" PM"; }else{ $temp[2]=" AM"; } $newtime=$temp[0].":".$temp[1].$temp[2];
quick and kludgy, and hey...it might even work...maybe...😉
hope this helps
well i tried to do something like this but it dont seam to work right. any ideas?
$t = '19:00:00'; $new_t = date('g:i A', mktime(substr($t,0,2), substr($t,3,2), substr($t,6,2), 0, 0, 0));
Couple of things.... you need to omit the date 0s Date with year, month and day equal to zero is considered illegal (otherwise it what be regarded as 30.11.1999, which would be strange behavior).
So try this-
$t = '21:30:00'; $temp=explode(":",$t); $new_t date('g:i A', mktime($temp[0], $temp[1], 0));
This function can do it
function create_date($format, $time, $tz) { if(empty($format)) { return @gmdate($time + (3600 * $tz)); } else { return @gmdate($format, $time + (3600 * $tz)); } }
All you do is
echo create_date("format of date here", "the time either unix or eg 12/12/02", "timezone");
Hope that helps