iPixel Posted March 24, 2010 Share Posted March 24, 2010 I have timestamps stored in the database 2010-03-24 14:15:00 for example. I need to take the time part of that timestamp and display it like so. 2:15pm. Any help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/196405-convert-time-stamp/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2010 Share Posted March 24, 2010 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format Quote Link to comment https://forums.phpfreaks.com/topic/196405-convert-time-stamp/#findComment-1031229 Share on other sites More sharing options...
Psycho Posted March 24, 2010 Share Posted March 24, 2010 Or in PHP: $date = '2010-03-24 14:15:00'; echo date('g:i a', strtotime($date)); //Output: 2:15 pm Not sure what is more efficient - extracting from MySQL in the desired format or converting in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/196405-convert-time-stamp/#findComment-1031242 Share on other sites More sharing options...
iPixel Posted March 24, 2010 Author Share Posted March 24, 2010 Like a glove, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/196405-convert-time-stamp/#findComment-1031249 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.