我将日期时间以这种格式存储在04-09-2019 10:31:AM
(2019年9月4日上午10:31)中。
我可以知道如何在sql查询中将此格式转换为unixtime
戳
答案 0 :(得分:3)
首先,您需要使用str_to_date()
函数将其转换为正确的 mysql 日期时间。
str_to_date(dd, '%d-%m-%Y %h:%i:%p')
然后在获得正确的 datetime 值之后,使用unix_timestamp()
函数将其转换为Unix时间戳。
select
unix_timestamp(str_to_date(dd, '%d-%m-%Y %h:%i:%p'))
from test
尝试dbfiddle。