獲得當前日期時間的mysql函數(shù)now()
如果想要獲得當前的日期和時間,應(yīng)該如何實現(xiàn)呢?使用mysql函數(shù)now() ,就可以實現(xiàn)這項我們需要的功能,下面就為您詳細介紹該mysql函數(shù),供您參考。
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
除了 now() 函數(shù)能獲得當前的日期時間外,MySQL 中還有下面的mysql函數(shù):
current_timestamp()
,current_timestamp
,localtime()
,localtime
,localtimestamp -- (v4.0.6)
,localtimestamp() -- (v4.0.6)
這些日期時間mysql函數(shù),都等同于 now()。鑒于 now() 函數(shù)簡短易記,建議總是使用 now() 來替代上面列出的mysql函數(shù)。
【編輯推薦】