教程集 www.jiaochengji.com
教程集 >  数据库  >  mysql  >  正文 mysql当前时间的获取函数示例

mysql当前时间的获取函数示例

发布时间:2015-12-03   编辑:jiaochengji.com
本文介绍下,在mysql中取得当前时间的函数,分别使用current_timestamp()、current_date()、current_time(),举几个小例子,供大家参考。

以下举三个例子,帮助大家学习mysql中获取当前日期与时间的方法,大家要细细体会mysql时间戳函数的具体用法。

一,使用current_timestamp()获取当前日期与时间
 

复制代码 代码示例:
mysql> select current_timestamp(); 
+---------------------+ 
| current_timestamp() | 
+---------------------+ 
| 2010-01-18 21:24:37 | 
+---------------------+ 
1 row in set (0.00 sec) 

二,使用current_date()获取当前日期
 

复制代码 代码示例:
mysql> select current_date(); 
+----------------+ 
| current_date() | 
+----------------+ 
| 2010-01-18     | 
+----------------+ 
1 row in set (0.00 sec) 

三,使用 current_time()获得当前时间
 

复制代码 代码示例:
mysql> select current_time(); 
+----------------+ 
| current_time() | 
+----------------+ 
| 21:24:46       | 
+----------------+ 
1 row in set (0.00 sec) 

您可能感兴趣的文章:
mysql获取系统当前时间的简单例子
mysql当前时间的获取函数示例
mysql获取系统当前时间的实例学习
mysql获取系统当前时间的函数
mysql获取当前时间的经典实例(2013最新版)
js获取当前系统时间实例代码
js date日期函数的例子
php 创建以unix时间戳命名的文件夹
MySQL日期数据类型、MySQL时间类型使用总结
js获取当前时间戳与日期比较

[关闭]
~ ~