Question

I'm probably doing something really silly here, but this isn't giving the expected output:

php > $time = "2011-05-05 20:15:29"; // Timestamp from MySQL database, in UTC.
php > date_default_timezone_set("America/New_York");
php > $ts = strtotime($time . " UTC");
php > strftime("%Y-%m-%d %H:%M:%S");
php > echo strftime("%Y-%m-%d %H:%M:%S");
2011-05-05 17:51:59

Year, month and day are correct, but everything (including seconds?) is off. Why?

Was it helpful?

Solution

Is this because you aren't passing arguement 2 to strftime?

echo strftime( "%Y-%m-%d %H:%M:%S", 1304626529 ); // 2011-05-05 20:15:29 UTC
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top