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 Quote Link to comment 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)); ?> Quote Link to comment 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. Quote Link to comment 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 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.