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