[SOLVED] Time conversions
Posted: Wed Oct 20, 2004 2:34 pm
The following code is used to convert times from a database into timestamps... it works for everything except for one of my items it is reading out the wrong AM/PM value, this is the only error i have
?>
Code: Select all
<?php
$atime='12:30:00'; // Set the time
$arrampm='PM'; // Set wether it is am or pm
$atime = "$atime:$arrampm"; // put the time and am/pm into one string
list($h, $m, $s, $a) = split(':', $atime); // get the hours minutes and seconds and ampm into their own strings
if ($a=="PM") { $h += 12; } // if it is in the pm add 12 hours to it to make 24 hour format time
$flightt = mktime($h, $m, $s, date("m"), date("d"), date("Y")); // make the timestamp
/// Then i echo out the readable format of the timestamp for debugging purposes, in this case it says AM instead of PM
echo date ("h:i:s A", $flightt);
?>