mysql 时间类型转换问题

版权声明:本文为博主原创文章,未经博主允许不得转载。github仓库:https://github.com/lzcwds,欢迎访问 https://blog.csdn.net/lzcwds/article/details/80105041

本文主要是时间戳/时间/字符串 三者之间的转换

时间转字符串

select date_format(now(), '%Y-%m-%d');  

时间转时间戳  

select unix_timestamp(now());

字符串转时间

select str_to_date('2018-04-27', '%Y-%m-%d %H');

字符串转时间戳

select unix_timestamp('2018-04-27');

时间戳转时间

select from_unixtime(1524797667000);

时间戳转字符串

select from_unixtime(1524797667000,'%Y-%d');  

猜你喜欢

转载自blog.csdn.net/lzcwds/article/details/80105041