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