warpdesign Posted August 31, 2006 Share Posted August 31, 2006 Hello, I'm having problems using strtotime. I'm pulling dates from a database, the dates are in the format:YYYY-MM-DD HH:MM:SSI want to reformat it so it's more user friendly, i.e.Sun, May 4 20064:30 PMI thought I could do this using strtotime and then reformating the date, but I get a strange number when I convert the string using that. Something like 1156723200...Do I then need to feed that number to another function? Also how do I convert it back to the original format to write back to the database? Quote Link to comment Share on other sites More sharing options...
Orio Posted August 31, 2006 Share Posted August 31, 2006 That 1156723200 is a [url=http://en.wikipedia.org/wiki/Unix_time]timestamp[/url].You use it now with the [url=http://www.php.net/manual/en/function.date.php]date()[/url] function to make the date formatted nicely.date("d, F jS Y, g:i A", $timestamp);Will come out nicely, when $timestamp is your number you got from strtotime().To format it back to your DB format, use date("Y-n-d H:i:s", $timestamp) ($timestamp is that number you got).Orio. Quote Link to comment Share on other sites More sharing options...
warpdesign Posted August 31, 2006 Author Share Posted August 31, 2006 Perfect. Thank you so much!! ;D 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.