Due to constant changes with the transition to winter-summer time in the Russian Federation, this time itself may be displayed on your
website and on the server incorrectly. In addition, PHP (if compiled without the
--with-system-tzdata option) and system time are different things. Therefore, you need to make two settings.
Somehow I suffered with finding a solution, there is a lot of scattered information in the internet, here is a “comprehensive” solution to this problem, I share ...
I have a “native” time zone
Europe / Moscow , but the time on the server ran forward by an hour, so I adjusted the timezone on
Europe / Kaliningrad on the server and in php. For PHP registered in
etc / php5 / apache2 / php.ini :
date.timezone = "Europe/Kaliningrad"
But these are crutches. We will do "for Feng Shui" ...
For PHP, you need to install or update
timezonedb :
pecl install timezonedb
or
pecl upgrade timezonedb
connect extension:
echo "extension=timezonedb.so" > /etc/php5/conf.d/timezonedb.ini
Restart the web server and enjoy ...
')
If you have not updated the database of time zones in the system, then download and install the latest version:
mkdir ~/timezone cd ~/timezone wget ftp://ftp.iana.org/tz/tzdata-latest.tar.gz tar zxvf tzdata-latest.tar.gz zic europe ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime
Some Linux distributions use a copy of the compiled file to
/ etc / localtime instead of a link.
Do not forget to remove the “crutches” if you have selected a suitable zone to adjust the time.