0

I made a small test page here since users on our system are reporting that the times they are seeing are incorrect. We are using date_default_timezone_set() with a value coming from a configuration file.

So what I tried is making this page:

echo 'TimeZone: ' . date_default_timezone_get() . "<br>";
echo 'Date & Time: ' . date('Y-m-d H:i:s');
----------------------------------------------------------
TimeZone: America/Chicago
Date & Time: 2020-04-07 13:33:20

And the output I'm getting is wrong however, at the time of running the time I should have gotten is 07:33 instead of 13:33 which is the time in Europe.

I thought there was something wrong with configuration or similar, so I tried adding the default timezone before the script as well, but that's returning the same wrong results:

date_default_timezone_set('America/Chicago');
echo 'TimeZone: ' . date_default_timezone_get() . "<br>";
echo 'Date & Time: ' . date('Y-m-d H:i:s');
-------------------------------------------------------
TimeZone: America/Chicago
Date & Time: 2020-04-07 13:37:24

Again, this time the time should be 07:37 in the actual timezone, but the date function is not returning the right function.

I saw another question here that it was something related to the server time, but it's set to the same thing as the previous hosting company that we had, using CentOS as well, so that doesn't seem to be the issue here.

kammy
  • 41
  • 1
  • 5
  • You can always edit manually your timezone in `php.ini`. This way it should work. Check [Setting the Timezone for PHP in the php.ini file](https://stackoverflow.com/questions/32224547/setting-the-timezone-for-php-in-the-php-ini-file) – Luca Apr 07 '20 at 11:45
  • Maybe there is another script overwriting it? – Rotimi Apr 07 '20 at 11:51
  • @Luca I have tried this, but it returned the same results, and unfortunately this would not work for us since we need different time-zones per-installation – kammy Apr 07 '20 at 12:08

0 Answers0