PHP timezone not set

后端 未结 3 2041
旧巷少年郎
旧巷少年郎 2020-12-03 23:06

First of all, i don\'t have access to the php.ini in the webserver.

In my local server I put date.timezone = \"Europe/Lisbon\" in my php.ini.

Is

相关标签:
3条回答
  • 2020-12-03 23:19

    On second thought, ini_set may not be the best way to go. Apparently E_STRICT standards say that you should use date_default_timezone_set instead.

    Try something like:

    date_default_timezone_set('Europe/Lisbon');
    
    $tz = date_default_timezone_get();
    

    More info can be found here about the issue: http://answers.google.com/answers/threadview/id/739376.html

    And here for the default_timezone functions:
    http://us2.php.net/manual/en/function.date-default-timezone-set.php

    Edit: I found this little gem while I was browsing github.

    // has to be set to reach E_STRICT compatibility, does not affect system/app settings
    date_default_timezone_set(date_default_timezone_get());
    

    This seems like the best solution.

    0 讨论(0)
  • 2020-12-03 23:22

    Try ini_set at the top of your script.

    ini_set("date.timezone", "Europe/Lisbon");
    
    0 讨论(0)
  • 2020-12-03 23:32

    Your problem is not difficult. You can change date.timezone in the php.ini and delete => ; <= is the comment in the php.ini

    for example [Date]

    ; Defines the default timezone used by the date functions

    ; http://php.net/date.timezone

    date.timezone =Europe/Paris

    http://www.commentcamarche.net/forum/affich-14406518-probleme-avec-l-heure-en-php

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