DBookatay Posted March 22, 2007 Share Posted March 22, 2007 Is there a code for converting a db field that is TIMESTAMP into "real time"? Meaning if the field is 2007-03-21 10:51:28 have is output: "10:51 am", Or: 2007-03-21 13:51:28 output: "1:51pm"? Any help would be apprechiated! Link to comment https://forums.phpfreaks.com/topic/43775-converting-timestamp-fields-into-real-time/ Share on other sites More sharing options...
fert Posted March 22, 2007 Share Posted March 22, 2007 http://us3.php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/43775-converting-timestamp-fields-into-real-time/#findComment-212539 Share on other sites More sharing options...
DBookatay Posted March 22, 2007 Author Share Posted March 22, 2007 Thanks for the help, but that page doesnt clearly explain my issue... Link to comment https://forums.phpfreaks.com/topic/43775-converting-timestamp-fields-into-real-time/#findComment-212547 Share on other sites More sharing options...
kenrbnsn Posted March 22, 2007 Share Posted March 22, 2007 You need to use a combination of the strtotime() function and the date() function: <?php $date1 = '2007-03-21 10:51:28'; $date2 = '2007-03-21 13:51:28'; echo 'date1: ' . date('g:i a',strtotime($date1)).'<br>'; echo 'date2: ' . date('g:i a',strtotime($date2)); ?> Ken Link to comment https://forums.phpfreaks.com/topic/43775-converting-timestamp-fields-into-real-time/#findComment-212549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.