mattl Posted April 6, 2008 Share Posted April 6, 2008 Hi, I've a table column called 'time' in mySQL TIME ie HH:MM:SS. I want to display the value in the format h:mm am/pm (20:00:00 becomes 8:30pm). Each value is returned through $row_events['time'] I don't really want to modify the mySQL query, so I've tried the following, but to no avail: Code: <?php echo time('%h:%i %p', ($row_events['time'])); ?> My brain has stopped working! Any suggestions on the above greatly appreciated. Thanks Matt Link to comment https://forums.phpfreaks.com/topic/99879-solved-php-time-display-203000-as-830pm/ Share on other sites More sharing options...
Barand Posted April 6, 2008 Share Posted April 6, 2008 <?php $time = '20:30:00'; echo date ('g:i a', strtotime($time)); ?> Link to comment https://forums.phpfreaks.com/topic/99879-solved-php-time-display-203000-as-830pm/#findComment-510812 Share on other sites More sharing options...
fenway Posted April 7, 2008 Share Posted April 7, 2008 You can use TIME_FORMAT() as a MySQL function. Link to comment https://forums.phpfreaks.com/topic/99879-solved-php-time-display-203000-as-830pm/#findComment-511212 Share on other sites More sharing options...
mattl Posted April 7, 2008 Author Share Posted April 7, 2008 Many thanks, got this working well now. Regards Matt Link to comment https://forums.phpfreaks.com/topic/99879-solved-php-time-display-203000-as-830pm/#findComment-511424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.