twilitegxa Posted August 21, 2008 Share Posted August 21, 2008 How do I format my timestamp to display the time and date like: 12-12-1998 05:45PM Or some similar format? I am confused as to how to write the PHP code. My timestamp is displayed liek this: 2008-08-20 19:20:11 Link to comment https://forums.phpfreaks.com/topic/120631-solved-timestamp-format-with-php/ Share on other sites More sharing options...
twilitegxa Posted August 21, 2008 Author Share Posted August 21, 2008 I also should mention I have it saved in my database, so I want to pull the date and time from the database and display it in a certain format. The field is named currenttime and I have it display with this code: echo $row['commenttime']; so I don't know how to add the formatting to this line. Link to comment https://forums.phpfreaks.com/topic/120631-solved-timestamp-format-with-php/#findComment-621597 Share on other sites More sharing options...
Daguse Posted August 21, 2008 Share Posted August 21, 2008 try date("m-d-y h:i:s A"); Best site you can use for small things is google or http://us.php.net/manual/en/index.php Link to comment https://forums.phpfreaks.com/topic/120631-solved-timestamp-format-with-php/#findComment-621598 Share on other sites More sharing options...
kenrbnsn Posted August 21, 2008 Share Posted August 21, 2008 You would use a combination of the strtotime() and date() functions: <?php $indate = '2008-08-20 19:20:11'; echo date('m-d-Y g:iA'); ?> Ken Link to comment https://forums.phpfreaks.com/topic/120631-solved-timestamp-format-with-php/#findComment-621600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.