如何将以下格式转换为Unix时间戳?
Apr 15 2012 12:00AM
我从数据库获得的格式似乎AM最后有。我尝试使用以下方法,但没有用:
AM
CONVERT(DATETIME, Sales.SalesDate, 103) AS DTSALESDATE, CONVERT(TIMESTAMP, Sales.SalesDate, 103) AS TSSALESDATE where Sales.SalesDate value is Apr 15 2012 12:00AM
试试这个查询 CONVERT DATETIME to UNIX TIME STAMP
CONVERT DATETIME to UNIX TIME STAMP
SELECT UNIX_TIMESTAMP(STR_TO_DATE('Apr 15 2012 12:00AM', '%M %d %Y %h:%i%p'))
此查询 CHANGE DATE FORMATE
CHANGE DATE FORMATE
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(STR_TO_DATE('Apr 15 2012 12:00AM', '%M %d %Y %h:%i%p')),'%m-%d-%Y %h:%i:%p')