PHP 時區 timezone 設定

php.ini找到

[Date]
;date.timezone =

改為

[Date]
date.timezone = "Asia/Taipei"

記得前面的冒號 ; 要拿掉
然後重新啟動apache即可

也有另外一種方式使用 php function

在php內只要輸入


 date_default_timezone_set("Asia/Taipei"); 或 ini_set("date.timezone", 'Asia/Taipei'); 
MYSQL讀取時區設定:
先查MySQL的時區設定,語法如下:
SHOW VARIABLES LIKE '%time_zone%';
若使用的是UTC(世界標準時間),我們的時區跟UTC差八小時,所以要執行下列的語法來變更:
SET TIME_ZONE='+8:00';
SHOW VARIABLES LIKE '%time_zone%';

若還是不行,則執行語法如下
將 NOW()改成
DATE_ADD(NOW(),INTERVAL 8 HOUR)
  • 1 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

Optimizing InnoDB Disk I/O

If you follow the best practices for database design and the tuning techniques for SQL...

如何透過SSH改變文件屬性與權限

我們現在知道文件權限對於一個系統的安全重要性了,也知道文件的權限對於使用者與群組的相關性, 那麼如何修改一個文件的屬性與權限呢?又!有多少文件的權限我們可以修改呢?...

wget 下載整個網站,或者特定目錄

我需要下載這個目錄下面的所有文件。命令如下 wget -c -r -np -k -L -p www.xxx.org/pub/path/ -c 斷點續傳 -r...

obtain the location of all files owned by this user

Code: # id username # find / -uid UIDNUMBER > /root/username.output Replace the first...