zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

【说站】MySQL获取当前时间和时间戳

mysql 获取 时间 当前
2023-06-13 09:13:21 时间

MySQL获取当前时间和时间戳

MySQL是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS应用软件之一。

本次介绍中,会让大家快速掌握MySQL获取当前时间和时间戳的方法,轻松使用MySQL数据库。

1、获得当前日期+时间(date + time)函数:now()

MySQL> select now();
+———————+
| now() |
+———————+
| 2013-04-08 20:56:19 |
+———————+

除了now()函数能获得当前的日期时间外,MySQL 中还有下面的函数:

current_timestamp()
,current_timestamp,localtime()
,localtime
,localtimestamp — (v4.0.6)
,localtimestamp() — (v4.0.6)
MySQL 时间戳(Timestamp)函数

2、MySQL 获得当前时间戳函数:current_timestamp, current_timestamp()

mysql> select current_timestamp, current_timestamp();
+——————————————+
| current_timestamp | current_timestamp() |
+——————————————+
| 2008-08-09 23:22:24 | 2008-08-09 23:22:24 |
+——————————————+

以上就是MySQL获取当前时间和时间戳,希望对大家有所帮助。