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教程
原文地址:https://www.jb51.cc/mysql/1209084.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。