PHP: System Timezone Setting error

狂风中的少年 提交于 2019-12-22 11:29:27

问题


I'm trying to use PHP in the terminal under MAMP but I got an error related to the system's timezone settings. How can I fix this error?

$/Applications/MAMP/bin/php5/bin/php echo.php

PHP Strict Standards: PHP Startup: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Manila' for 'PHT/8.0/no DST' instead in Unknown on line 0


回答1:


You need to set date.timezone in the php.ini fileDocs

// London, England, Europe
date.timezone = "Europe/London"
date.default_latitude = 51.500181
date.default_longitude = -0.12619

or

 date.timezone = America/Los_Angeles



回答2:


Set the default time zone manually at the beginning of your code:

date_default_timezone_set('Europe/Berlin');


来源:https://stackoverflow.com/questions/4533252/php-system-timezone-setting-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!