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 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

Limit mysql connections on a per account.

You can set this in /etc/my.cnf max_connections=100 max_user_connections=25 You might find...

使用mod_limitipconn 限制單線下載教學

# wget http://dominia.org/djao/limit/mod_limitipconn-0.23.tar.bz2# tar xjf...

How To Install and Testing Memcache PHP Extension?

Create file test.php [code]$vi /home/www/public_html/test.php [/code] Execute test.php from...

Add Install mod_rpaf on CentOS 5, CentOS 6

This is a quick guide on how to install mod_rpaf on CentOS 5 and CentOS 6. (This guide can also...

Resize the /tmp and /usr/tmpDSK for cPanel

You can resize it if it isn't large enough. Many servers have only 500MB for /tmp which isn't...