JSHINER Posted July 6, 2007 Share Posted July 6, 2007 I am working with a database where dates / times are stored as: 2007-07-01 13:00:00 I use: <?php echo date("F j, Y",strtotime($var)); ?> To display the date as: July 1, 2007 How can I get the 13:00:00 to display as "1:00 p.m." ? Link to comment https://forums.phpfreaks.com/topic/58773-solved-help-with-date-and-time/ Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 www.php.net/date It should have h for hours i for minutes s for seconds and there should be an am/pm key too. Look through that table to find the combination you need. Link to comment https://forums.phpfreaks.com/topic/58773-solved-help-with-date-and-time/#findComment-291577 Share on other sites More sharing options...
JSHINER Posted July 6, 2007 Author Share Posted July 6, 2007 Wow that was easy Thanks! Link to comment https://forums.phpfreaks.com/topic/58773-solved-help-with-date-and-time/#findComment-291582 Share on other sites More sharing options...
akitchin Posted July 6, 2007 Share Posted July 6, 2007 you can also use MySQL's built-in functions for formatting dates and times. it's probably actually more efficient to do so. have a look in the MySQL manual for functions like DATE_FORMAT(). Link to comment https://forums.phpfreaks.com/topic/58773-solved-help-with-date-and-time/#findComment-291584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.