"Server" Timezone does not change to PHP

I installed Hestia. And the time zone has already been set correct in the settingstimezone

And it ok in mysql NOW() - 2020-05-14 04:04:51

But in php date(DATE_ATOM) it is not work - PHP shows zero zone time - 2020-05-14T01:04:52+00:00

I 'm not sure, but it seems that in Vesta the time of PHP changed too

Should Hestia change this field based on the settings in the interface or is this option left specifically for console fans?

For me, if i goto my website and do ‘info.php’ - it shows my local time correctly with timezone.

That’s always been a quirk of PHP: every time you first install PHP on any system, the first thing you need to do is edit the php.ini files and set the “date.timezone” value manually. In your case, just edit both /etc/php/7.0/fpm/php.ini and /etc/php/7.0/cli/php.ini, uncomment the “date.timezone” line, and change its value to “Europe/Moscow”:

date.timezone = Europe/Moscow

And keep in mind that you will also have to do that manual edit of the php.ini files when you install versions 7.1, 7.2, 7.3, and so forth.

–Dan

4 Likes

Thats why it is always a good practice to set default timezone inside your PHP application wherever possible, so that you don’t reply on server’s timezone.

Wow! So it was possible? )
Excellent simple idea

I never use mysql NOW () - always the current time I insert from PHP into the query.

But why Hestia did not change the timezone in php.ini? It’s kind of simple. Or there may be some mistakes?

I checked - Hestia through the interface /edit/server/php-fpm/ have changed the time zone for all in php fpm and cli options.