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?
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?
According to the documentation of
date_default_timezone_get
, thedate.timezone
configuration option can be overridden by setting theTZ
environement variable (which, in turn, can be overridden by callingdate_default_timezone_set
). From your description, I suspect that theTZ
environement veriable is set.I suggest always using date_default_timezone_set() from script
e.g.
or
...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 inphp.ini
or its setting is incorrect. It's also handy when you can't access and/or modifyphp.ini
(shared hosting).Also, be sure that you've not used
;
at the and of line inphp.ini
.Restart server after changing
php.ini
.I know this is an old question. If you are using a PHP framework, you might want to check the config file of the framework. For example in Laravel, open the
config/app.php
and you will find timezone there. Set it to your timezone.You need to reload the configuration / restart the server after editing your php.ini file.
by default it shows GMT time you can change for your region with following code
List of Supported Timezones http://www.php.net/manual/en/timezones.php
Edit
php.ini
and restart Apache:php.ini
(go to PHP -> php.ini)date.timezone
valuedate.timezone
byphpinfo();