MySQL中字符串转日期
str_to_date(date,’%Y-%m-%d’)
MySQL中日期转字符串
date_format(date,’%Y-%m-%d’)
例如:
日期转字符串
select date_format(now(),'%m-%d ^H:%i')
//得到的的结果是
10-12 15:03
同理
字符串转日期
select str_to_date(‘09/01/2009’,’%m/%d/%Y’)
// 2009-09-01
select str_to_date(‘20140422154706’,’%Y%m%d%H%i%s’)
// 2014-04-22 15:47:06
select str_to_date(‘2014-04-22 15:47:06’,’%Y-%m-%d %H:%i:%s’)
// 2014-04-22 15:47:06