mysql 时间转化函数

获取当前时间戳

select unix_timestamp();
  • 1

select unix_timestamp(now());
  • 1

获取当前时间

select now();
  • 1

时间转时间戳

select unix_timestamp('2018-01-15 09:45:16');
  • 1

时间戳转时间

select from_unixtime(1515980716);
  • 1

时间戳格式化

SELECT from_unixtime(1515980716, '%Y-%m-%d %H:%i:%S');
  • 1

时间格式化

select date_format(now(), '%Y-%m-%d');
select date_format('2018-01-15 09:45:16', '%Y-%m-%d');
  • 1
  • 2

可视化转换

http://tool.chinaz.com/Tools/unixtime.aspx

mysql
mysql

posted @ 2018-12-24 11:53  liulonglong  阅读(195)  评论(0编辑  收藏  举报