php時間設置爲本地


PHP Warning: 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_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 'UTC' for '8.0/no DST' instead in D:\PHPWEB\news\file.php on line 17 。這是由於PHP所取的時間是格林威治標準時間,因此和你當地的時間會有出入格林威治標準時間和北京時間大概差8個小時左右,咱們能夠按照下面的方法解決: 
一、在頁頭使用date_default_timezone_set()設置默認時區爲北京時間,即 <?php date_default_timezone_set("PRC"); ?>就能夠了。 
二、在php.ini中設置date.timezone的值爲PRC,設置好之後的爲:date.timezone=PRC,同時取消這一行代碼的註釋,即去掉前面的分號就能夠了。 php

相關文章
相關標籤/搜索