PHP 日期相關
<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)