mysql时间与字符串转换

str_to_date(str,format):字符串转时间

select str_to_date('2018-02-23 15:01:51', '%Y-%m-%d %H:%i:%s') date;


date_format(date,format):时间转字符串

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

演示

  


MySQL 日期格式化(format)的取值范围:
 

猜你喜欢

转载自www.cnblogs.com/gered/p/11345713.html