資料庫 mysql如何獲取當前時間

2021-08-16 00:14:30 字數 688 閱讀 8309

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如何獲取當前時間

1.1 獲得當前日期 時間 date time 函式 now 除了 now 函式能獲得當前的日期時間外,mysql 中還有下面的函式 current timestamp current timestamp localtime localtime localtimestamp localtimesta...

mysql檢視 MySQL檢視當前資料庫庫

mysql檢視當前資料庫庫 1 在mysql下檢視當前使用的是哪個資料庫,有三種方式 用select database 語句 mysql select database database test row in set 0.00 sec 從查詢結果中可以看出,當前用的是test資料庫 2 用show...

mysql如何獲取當前時間

1.1 獲得當前日期 時間 date time 函式 now 除了 now 函式能獲得當前的日期時間外,mysql 中還有下面的函式 current timestamp current timestamp localtime localtime localtimestamp localtimesta...