0

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?

2
  • What is the output you are getting from line 3? Commented May 5, 2011 at 21:58
  • 5
    arent you supposed to pass $ts to the strftime function call? Commented May 5, 2011 at 22:01

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

2 Comments

Like I said, I was probably doing something silly. Head was firmly planted into wall here.
@Thanatos, happens to all of us :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.