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?
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
.
Edit php.ini
and restart Apache:
php.ini
(go to PHP -> php.ini)date.timezone
value;date.timezone = UTC date.timezone = Europe/Kiev
date.timezone
by phpinfo();
You need to reload the configuration / restart the server after editing your php.ini file.
According to the documentation of date_default_timezone_get
, the date.timezone
configuration option can be overridden by setting the TZ
environement variable (which, in turn, can be overridden by calling date_default_timezone_set
). From your description, I suspect that the TZ
environement veriable is set.
by default it shows GMT time you can change for your region with following code
date_default_timezone_set("Asia/Bangkok");//set you countary name from below timezone list
echo $date = date("Y-m-d H:i:s", time());//now it will show "Asia/Bangkok" or your date time
List of Supported Timezones http://www.php.net/manual/en/timezones.php
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.
... That should do it. 3. Restart your server