Wrong PHP date() output in wamp server

anon picture anon · Apr 22, 2011 · Viewed 21.7k times · Source

The problem is that date('r') returns wrong time for my timezone.

php.ini timezone setting:
date.timezone = Europe/Kiev

date_default_timezone_set('Europe/Kiev') in my script solves the problem.

So what's wrong with WAMP?

Answer

Wh1T3h4Ck5 picture Wh1T3h4Ck5 · Apr 22, 2011

I suggest always using date_default_timezone_set() from script

e.g.

date_default_timezone_set('Europe/Kiev');

or

ini_set('date.timezone', 'Europe/Kiev');

...to avoid PHP guessing timezone.

It comes handy when you transfer code to different server(s), for example, outside of Ukraine. This line should help you to avoid unexpected (wrong) results if date.timezone is not set in php.ini or its setting is incorrect. It's also handy when you can't access and/or modify php.ini (shared hosting).

Also, be sure that you've not used ; at the and of line in php.ini.

Restart server after changing php.ini.