VDS Ubuntu 16.04 + VestaCP. PHP Script returns the time of different time zones depending on how it is launched.

Script 1.php:

<?php echo date('ymd Hi-s'); 

a call from the browser site.ru/1.php issues

18-10-11 01-44-16 - the current time in my time zone (+3).

and calling the same script from the ssh command line on the server # # php / path_to_file/1.php:

18-10-10 22-44-16 is the current GMT time (+0).

PHP settings /etc/php/7.0/apache2/php.ini:

 ... [Date] date.timezone = "Europe/Moscow" ... 

How to make both ways return Moscow time +3?

1 answer 1

The script returns the time of different time zones depending on how it is launched.

for different ways to run PCP uses different configs. In the case of using web-server, this is the php.ini you give, in the case of its use in the console it is php_cli.ini . Therefore, make sure that in the last of them the timezone value matches the desired one

  • thanks, earned. - Ruport