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? Link to comment https://forums.phpfreaks.com/topic/19238-strtotime-problem-help/ 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. Link to comment https://forums.phpfreaks.com/topic/19238-strtotime-problem-help/#findComment-83332 Share on other sites More sharing options...
warpdesign Posted August 31, 2006 Author Share Posted August 31, 2006 Perfect. Thank you so much!! ;D Link to comment https://forums.phpfreaks.com/topic/19238-strtotime-problem-help/#findComment-83574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.