mysql怎么获取当前时间

2023年 4月 18日 16.0k 0

mysql获取当前时间的方法:可以通过执行【select now();】语句来获取当前时间。还可以通过执行【select current_timestamp, current_timestamp();】语句来获取。 获得当前日期+时间(date + time)函数

mysql获取当前时间的方法:可以通过执行【select now();】语句来获取当前时间。还可以通过执行【select current_timestamp, current_timestamp();】语句来获取。

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

(推荐教程:mysql视频教程)

mysql> select now();

+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+

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

sysdate() 日期时间函数跟 now() 类似,不同之处在于:now() 在执行开始时值就得到了, sysdate() 在函数执行时动态得到值。看下面的例子就明白了:

mysql> select now(), sleep(3), now();

+---------------------+----------+---------------------+
| now() | sleep(3) | now() |
+---------------------+----------+---------------------+
| 2008-08-08 22:28:21 | 0 | 2008-08-08 22:28:21 |
+---------------------+----------+---------------------+

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教程

以上就是mysql怎么获取当前时间的详细内容,更多请关注每日运维其它相关文章!

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论