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! Quote Link to comment 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 Quote Link to comment 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... Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.