1

This PHP statement date('Y-m-d',1281394800) returns different values in different servers. One gives me 2010-08-09 and the other 2010-08-10. Could someone please help explain?

2
  • 6
    have you checked the timezone? Commented Aug 5, 2010 at 21:36
  • 1
    I would imagine it's a timezone thing. Commented Aug 5, 2010 at 21:36

3 Answers 3

2

Try this and see if you still get different results:

date_default_timezone_set('UTC');
echo date('Y-m-d',1281394800);

If you get exactly the same results across servers, you can set the timezone to the one you want. For more information:

date_default_timezone_set

List of Supported Timezones

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this was the problem. I havent been keen on the time zone until it bit me here! Thanks for all who responded about the timezone.
1

Are the servers in (or configured with) different timezones?

date()'s output is timezone-dependent.

Comments

1

Set the time zone:

date_default_timezone_set('UTC');
echo date('Y-m-d',1281394800);

date_default_timezone_set — Sets the default timezone used by all date/time functions in a script

Comments

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.