MySQL 字符串转换为日期

MySQL Str to Date (字符串转换为日期)
函数:str_to_date(str, format)
select str_to_date( '08/09/2008' , '%m/%d/%Y' ); -- 2008-08-09
select str_to_date( '08/09/08' , '%m/%d/%y' ); -- 2008-08-09
select str_to_date( '08.09.2008' , '%m.%d.%Y' ); -- 2008-08-09
select str_to_date( '08:09:30' , '%h:%i:%s' ); -- 08:09:30
select str_to_date( '08.09.2008 08:09:30' , '%m.%d.%Y %h:%i:%s' ); -- 2008-08-09 08:09:3
select date_format(now(),'%Y-%m-%d %T')
----当前时间---2017-06-01 09:33:42

猜你喜欢

转载自blog.csdn.net/corpse2010/article/details/80340013