码迷,mamicode.com
首页 > 数据库 > 详细

mysql时间、字符串、时间戳互相转换

时间:2020-01-11 00:09:11      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:_for   unix   select   字符   sql   sel   sele   form   date   

时间转字符串
select date_format(now(), ‘%Y-%m-%d %H:%i:%s’); 
结果:2018-05-02 20:24:10
时间转时间戳
select unix_timestamp(now()); 
结果:1525263383
字符串转时间
select str_to_date(‘2018-05-02’, ‘%Y-%m-%d %H’); 
结果:2018-05-02 00:00:00
字符串转时间戳
select unix_timestamp(‘2018-05-02’); 
结果:1525263383
时间戳转时间
select from_unixtime(1525263383); 
结果:2018-05-02 20:16:23
时间戳转字符串
select from_unixtime(1525263383, ‘%Y-%m’); 
结果:2018-05

mysql时间、字符串、时间戳互相转换

标签:_for   unix   select   字符   sql   sel   sele   form   date   

原文地址:https://www.cnblogs.com/fangyan1994/p/12178654.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!