如何在 mysql 中单独将此日期转换为 unix 时间戳?

How to convert this date into a unix timestamp in mysql alone?

这是日期:2018-01-25T13:39:40-05:00
来自 API.

到目前为止,我这样做了:SELECT UNIX_TIMESTAMP(STR_TO_DATE('2018-01-25T13:39:40-05:00', '%M %d %Y %h:%i%p')) AS time

但它给了我 NULL
我认为 -05:00 是时区。但是T是,我不知道。

也许还有另一种方法可以去掉 T 和 -05:00 并将 24 小时转换为 12 小时

您不必使用 STR_TO_DATE 函数。

可以直接使用UNIX_TIMESTAMP。

UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC.

The date argument may be a DATE, DATETIME, or TIMESTAMP string, or a number in YYMMDD, YYMMDDHHMMSS, YYYYMMDD, or YYYYMMDDHHMMSS format.

The server interprets date as a value in the current time zone and converts it to an internal value in UTC. Clients can set their time zone

https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp

SELECT UNIX_TIMESTAMP('2018-01-25T13:39:40-05:00') AS time

http://sqlfiddle.com/#!9/b2206f/1