这篇文章主要介绍了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如何获取当前时间和时间戳”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“MySQL如何获取当前时间和时间戳”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注天达云行业资讯频道。