abs0lut Posted August 16, 2008 Share Posted August 16, 2008 I need to show if the date is am/pm, do I need to insert am/pm in the database? the data type is datetime could you please help me? Link to comment https://forums.phpfreaks.com/topic/119927-do-i-need-to-insert-ampm-in-the-database/ Share on other sites More sharing options...
kenrbnsn Posted August 16, 2008 Share Posted August 16, 2008 No, a datetime value has the time stored as a 24 hour clock. You would used a combination of the date() and strtotime() functions: <?php $datestr = '2008-08-08 18:48:39'; // assume this was just pulled from the database echo date('g:i A',strtotime($datestr)); ?> Ken Link to comment https://forums.phpfreaks.com/topic/119927-do-i-need-to-insert-ampm-in-the-database/#findComment-617802 Share on other sites More sharing options...
Gighalen Posted August 16, 2008 Share Posted August 16, 2008 Or you could use a timestamp - just be sure to include the A (Capital A, like in kens example above) in your date format, like so: <?php $time = time(); $date = date('D, M j, Y, g:i A', $time); ?> Link to comment https://forums.phpfreaks.com/topic/119927-do-i-need-to-insert-ampm-in-the-database/#findComment-617822 Share on other sites More sharing options...
abs0lut Posted August 16, 2008 Author Share Posted August 16, 2008 thank you very much Link to comment https://forums.phpfreaks.com/topic/119927-do-i-need-to-insert-ampm-in-the-database/#findComment-617852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.