20101109-240000 or 20101109-235959
How to convert the date开发者_开发技巧 format above into MySQL format, Y-m-d H:i:s
Thank You
$mysqldate = preg_replace('/(\d{4})(\d{2})(\d{2})\-(\d{2})(\d{2})(\d{2})/', '$1-$2-$3 $4:$5:$6',$date)
Use STR_TO_DATE() MySQL function :
SELECT STR_TO_DATE('20101109-235959', '%Y%m%d-%H%i%s');
-- 2010-11-09 23:59:59
P.S. 20101109-240000 wouldn't work because it is not a valid timestamp.
精彩评论