<strong>代碼:</strong> mysql> select NOW(), TO_DAYS(NOW()), CURDATE(), TO_DAYS(CURDATE()); +---------------------+----------------+------------+--------------------+ | NOW() | TO_DAYS(NOW()) | CURDATE() | TO_DAYS(CURDATE()) | +---------------------+----------------+------------+--------------------+ | 2007-01-25 13:11:53 | 733066 | 2007-01-25 | 733066 | +---------------------+----------------+------------+--------------------+ 1 row in set (0.00 sec) mysql> select TO_DAYS(NOW())-10, TO_DAYS(CURDATE())-10; +-------------------+-----------------------+ | TO_DAYS(NOW())-10 | TO_DAYS(CURDATE())-10 | +-------------------+-----------------------+ | 733056 | 733056 | +-------------------+-----------------------+ 1 row in set (0.00 sec) mysql> select NOW(), FROM_DAYS(TO_DAYS(NOW())-10), CURDATE(), FROM_DAYS(TO_DAYS(CURDATE())-10); +---------------------+------------------------------+------------+----------------------------------+ | NOW() | FROM_DAYS(TO_DAYS(NOW())-10) | CURDATE() | FROM_DAYS(TO_DAYS(CURDATE())-10) | +---------------------+------------------------------+------------+----------------------------------+ | 2007-01-25 13:12:07 | 2007-01-15 | 2007-01-25 | 2007-01-15 | +---------------------+------------------------------+------------+----------------------------------+ 1 row in set (0.00 sec)
KennyWriter
Keep Writing.
PHP 日期相關
將伺服器的時區改變
先找到 php.ini
裡面會有以下的 code
[Date] ; Defines the default timezone used by the date functions ;date.timezone =
改成
[Date] ; Defines the default timezone used by the date functions date.timezone = Asia/Taipei
php寫入lunarpages mysql 的伺服器日期格式
<?php echo date (‘Y-n-d G:i:s’,time() + 54000); ?>
ixwebhosting 的是
<?php echo date (‘Y-n-d G:i:s’,time() + 43200); ?>
附註:
54000秒 = 16 個小時
43200秒 = 12 個小時