新聞中心
數(shù)據(jù)庫中日期和時間都是很重要的,下面就為您介紹幾個和MySQL日期時間相關(guān)的函數(shù),供您參考,希望對您學(xué)習(xí)MySQL日期時間方面有所幫助。

獲得當(dāng)前日期(date)函數(shù):curdate()
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2008-08-08 |
+------------+
其中,下面的兩個日期函數(shù)等同于 curdate():
current_date()
,current_date
獲得當(dāng)前時間(time)函數(shù):curtime()
mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 22:41:30 |
+-----------+
其中,下面的兩個時間函數(shù)等同于 curtime():
current_time()
,current_time
獲得當(dāng)前 UTC 日期時間函數(shù):utc_date(), utc_time(), utc_timestamp()
mysql> select utc_timestamp(), utc_date(), utc_time(), now()
+---------------------+------------+------------+---------------------+
| utc_timestamp() | utc_date() | utc_time() | now() |
+---------------------+------------+------------+---------------------+
| 2008-08-08 14:47:11 | 2008-08-08 | 14:47:11 | 2008-08-08 22:47:11 |
+---------------------+------------+------------+---------------------+
因?yàn)槲覈挥跂|八時區(qū),所以本地時間 = UTC 時間 + 8 小時。UTC 時間在業(yè)務(wù)涉及多個國家和地區(qū)的時候,非常有用。
以上就是MySQL日期的相關(guān)函數(shù)介紹。
【編輯推薦】
帶您深入了解MYSQL Cast函數(shù)
MySQL字符串處理函數(shù)concat_ws()
查看三種MySQL字符集的方法
MySQL外鍵在數(shù)據(jù)庫中的作用
MySQL外鍵的相關(guān)語法
分享題目:MySQL日期的相關(guān)函數(shù)介紹
轉(zhuǎn)載源于:http://www.dlmjj.cn/article/ccccpii.html


咨詢
建站咨詢
