mysql 获取系统时间及其格式
2013-01-25 09:58
288 查看
mysql>select now();
+---------------------+ |
now() | +---------------------+
| 2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)
mysql>select sysdate();
+---------------------+ | sysdate() | +---------------------+ |2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)
mysql>select curdate(); +------------+ | curdate() | +------------+ |2011-06-11 | +------------+ 1 row in set (0.00 sec)
mysql> select current_date; +--------------+ | current_date | +--------------+ |2011-06-11 | +--------------+ 1 row in set
(0.00 sec)
mysql> select curtime(); +-----------+ | curtime() | +-----------+ | 12:00:54 | +-----------+ 1 row in set (0.00 sec)
mysql>select current_time; +--------------+ | current_time | +--------------+ |12:00:54 | +--------------+ 1 row in set (0.00
sec)
2. mysql (unix 时间戳、日期)转换函数:
unix_timestamp(),unix_timestamp(date),from_unixtime(unix_timestamp),from_unixtime(unix_timestamp,format)
下面是示例:
select unix_timestamp(); -- 1218290027 ===得到当前时间的unix时间值
将具体时间来转换成timestamp
select unix_timestamp('2008-08-08'); -- 1218124800select unix_timestamp('2008-08-08 12:30:00'); -- 1218169800
将timestamp来转换成具体时间select from_unixtime(1218290027); -- '2008-08-09 21:53:47'select from_unixtime(1218124800); -- '2008-08-08 00:00:00'select from_unixtime(1218169800); -- '2008-08-08 12:30:00'
select from_unixtime(1218169800, '%y %d %m %h:%i:%s %x'); -- '2008 8th august 12:30:00 2008'
+---------------------+ |
now() | +---------------------+
| 2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)
mysql>select sysdate();
+---------------------+ | sysdate() | +---------------------+ |2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)
mysql>select curdate(); +------------+ | curdate() | +------------+ |2011-06-11 | +------------+ 1 row in set (0.00 sec)
mysql> select current_date; +--------------+ | current_date | +--------------+ |2011-06-11 | +--------------+ 1 row in set
(0.00 sec)
mysql> select curtime(); +-----------+ | curtime() | +-----------+ | 12:00:54 | +-----------+ 1 row in set (0.00 sec)
mysql>select current_time; +--------------+ | current_time | +--------------+ |12:00:54 | +--------------+ 1 row in set (0.00
sec)
2. mysql (unix 时间戳、日期)转换函数:
unix_timestamp(),unix_timestamp(date),from_unixtime(unix_timestamp),from_unixtime(unix_timestamp,format)
下面是示例:
select unix_timestamp(); -- 1218290027 ===得到当前时间的unix时间值
将具体时间来转换成timestamp
select unix_timestamp('2008-08-08'); -- 1218124800select unix_timestamp('2008-08-08 12:30:00'); -- 1218169800
将timestamp来转换成具体时间select from_unixtime(1218290027); -- '2008-08-09 21:53:47'select from_unixtime(1218124800); -- '2008-08-08 00:00:00'select from_unixtime(1218169800); -- '2008-08-08 12:30:00'
select from_unixtime(1218169800, '%y %d %m %h:%i:%s %x'); -- '2008 8th august 12:30:00 2008'
相关文章推荐
- mysql 获取系统时间及其格式
- MySQL获取系统当前时间的函数
- MySql获取系统时间
- 获取系统时间,计算时间差,各种时间格式之间转换
- mysql 获取系统时间
- Mysql中怎么获取当前系统时间
- Windows 驱动:获取系统当前时间,生成格式字符串
- 【转】QT获取系统时间,以及设置日期格式
- mysql获取系统当前的数字形式时间值
- 系统获取时间的格式要存进数据库要进行格式转换
- C++获取系统时间如何插入到MySQL里面的datetime型属性中
- 获取系统时间格式
- android 日期时间格式转换;软键盘显示消失;获取系统title
- 获取系统时间以及时间显示的格式
- C++获取系统时间和格林制(GMT)时间函数,并按一定格式输出
- Android TextClock获取系统时间,格式跟随设置改变
- Java 获取系统当前时间,格式(2015-05-06 21:26:39.82)
- MySQL获取系统当前时间的函数和centos修改时间
- Object-C获取系统当前时间(指定格式)
- MySQL获取系统当前时间的函数