MySQL時間函數

1. now

now() 返回當前時間戳
2018-11-11 11:11:11
select now();

2. UNIX_TIMESTAMP

返回時間值
select UNIX_TIMESTAMP('2017-06-10 13:02:18');
--1497070938

3. FROM_UNIXTIME

返回時間戳
select FROM_UNIXTIME(1497070938, '%Y-%m-%d %H:%i:%S');
--2017-06-10 13:02:18
select FROM_UNIXTIME(1497070938);
--2017-06-10 13:02:18

4. curtime

返回當前時間
time(now()),current_time();
select curtime(),current_time(),time(now());

5. curdate

返回當前日期
date(now()),current_date();
select curdate(),current_date(),date(now());

6.datediff

日期差
select datediff('2008-08-08', '2008-08-01'); 
-- 7
相關文章
相關標籤/搜索