Your date format string should be '%Y-%m-%d %H:%i:%s'
.
%m
means month, and %h
means USA-style 0-12 hours, so 13 is no good.
Using STR_TO_DATE is almost as much fun as whistling into a modem, but not quite. :-)
题
SELECT UNIX_TIMESTAMP(STR_TO_DATE('2014-05-10 13:12:44','%Y-%m-%d %h:%m:%s'));
returns NULL. Am I missing something? I thought this would return a timestamp.
解决方案
Your date format string should be '%Y-%m-%d %H:%i:%s'
.
%m
means month, and %h
means USA-style 0-12 hours, so 13 is no good.
Using STR_TO_DATE is almost as much fun as whistling into a modem, but not quite. :-)