數據庫——mysql如何獲取當前時間

數據庫——mysql如何獲取當前時間 html

1.1 得到當前日期+時間(date + time)函數:now() 

除了 now() 函數能得到當前的日期時間外,MySQL 中還有下面的函數: 

current_timestamp() current_timestamp 

localtime() localtime 

localtimestamp() localtimestamp 

這些日期時間函數,都等同於 now()。鑑於 now() 函數簡短易記,建議老是使用 now() 來替代上面列出的函數。

1.2 得到當前日期+時間(date + time)函數:sysdate()

sysdate() 日期時間函數跟 now() 相似,不一樣之處在於:now() 在執行開始時值就獲得了, sysdate() 在函數執行時動態獲得值。

2. 得到當前日期(date)函數:curdate() 

其中,下面的兩個日期函數等同於 curdate(): current_date(),current_date 

3. 得到當前時間(time)函數:curtime() 

其中,下面的兩個時間函數等同於 curtime():current_time(),current_time 

4. 得到當前 UTC 日期時間函數:utc_date(), utc_time(), utc_timestamp()mysql

相關文章
相關標籤/搜索