PHP wrong date/time

后端 未结 7 1181
南笙
南笙 2021-02-19 13:28

PHP date() & time() return incorrect time:

When date.timezone = \"Europe/Riga\" the time returned by date() was <

相关标签:
7条回答
  • 2021-02-19 13:58

    The problem looks similar to what I have seen on one of my servers. Looks to like bug in php 5.3.2-1. Try to run the php script in the bug report and post your results.

    0 讨论(0)
  • 2021-02-19 13:58

    The timezone of the system could be wrong. This results in a shift in a time given by the PHP date() function, althought both php date.timezone (in php.ini) and system time of the server are correct.

    0 讨论(0)
  • 2021-02-19 13:59

    You have to set date.timezone in php.ini and restart your server http://php.net/manual/en/timezones.php

    0 讨论(0)
  • 2021-02-19 14:03

    This comment for Azerbaijan timezone

    I have problem with 'Asia/Baku' on php 7.2 or php 7.1 version.

    I solved problem change to 'Europe/Baku'

    0 讨论(0)
  • 2021-02-19 14:06

    PHP time is based on epoch time scale which uses GMT and later UTC. Most people now refer to it as unix time. Because PHP uses unix time, timezones are not used. I believe subtracting the timezone hours in seconds is the correct method to adjust for the differences.

    0 讨论(0)
  • 2021-02-19 14:07

    Reading PHP manual seems that behaviour of date.timezone is affected by settings in php.ini. There is another way to set the default timezone in all date/time function and it's the date_default_timezone_set. Try to set it with:

    date_default_timezone_set('Europe/Riga');
    

    instead of your date.timezone code.

    0 讨论(0)
提交回复
热议问题