mysql 日期、时间操作

mysql 日期、时间操作笔记

--时间转字符串
select date_format(now(), '%Y-%m-%d %H:%i:%s'); 
--时间转时间戳
select unix_timestamp(now());
--字符串转时间
select str_to_date('2016-01-02', '%Y-%m-%d %H'); 
--字符串转时间戳
select unix_timestamp('2016-01-02');
--时间戳转字符串
select from_unixtime(1451997924,'%Y-%d'); 

--今天0时
new Date(new Date(new Date().toLocaleDateString()).getTime())
--昨天0时
new Date(new Date(new Date().toLocaleDateString()).getTime()-24*3600*1000)

猜你喜欢

转载自blog.csdn.net/u012842714/article/details/103716383