Stop Warning: date() [function.date]: from localhost

后端 未结 5 1403
半阙折子戏
半阙折子戏 2021-02-19 20:09

Warning: date() [function.date]: It is not safe to rely on the system\'s timezone settings. You are required to use the date.timezone setting or the date

相关标签:
5条回答
  • 2021-02-19 20:17

    As the warning says...

    use the date.timezone setting

    Just configure this with your timezone in php.ini, and all will be well for all apps on your server.

    EDIT If you are still having this problem after having configured this, you will probably find that your system uses more than one php.ini file. To find out which ini file is used for your web server, use phpinfo().

    0 讨论(0)
  • 2021-02-19 20:28

    to remove this warning from your project

    There are 2 ways to do so...

    1) date_default_timezone_set('Asia/Kolkata'); include this file in your index.php file This will work only for your current project

    2) date_default_timezone_set('Asia/Kolkata'); or inlude this file in your php.ini file This will work for every project

    thnx :)

    0 讨论(0)
  • 2021-02-19 20:29

    The reason it is happending on one server and not the other is the php.ini setting date.timezone=.

    You would still need to pick an actual value though. You assuredly don't have one. Or in the wrong php.ini version (there's one for CLI and one for mod_php).

    0 讨论(0)
  • 2021-02-19 20:30

    It works by setting

    date.timezone = Asia/Calcutta
    

    For details go to: PHP Documentation - Asia Timezones

    0 讨论(0)
  • 2021-02-19 20:37

    As the other posters have mentioned, setting date.timezone in the php.ini file is the way to go. If you are still seeing the error about needing to set it, did you restart your web server (apache, IIS, etc) after setting the php.ini?

    Also, the warning from phpinfo means the rest of the output should still be showing. Make sure you're editing the correct php.ini file according to the phpinfo() output.

    That will likely get you working as you'd like.

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