你好,
我以这种格式存储 mysql 日期:
在我的 sql 查询中,我想以 UTC 格式获取这些日期。 我已经尝试过 CONVERT_TZ(dt,from_tz,to_tz)function 但我无法确定如何从 from_tz 获取日期。我知道 to_tz 将是 'UTC' 或 '+0000'
最佳答案
试试这个:
select convert_tz(`date`, replace(substring_index(`date`, ' ', -1), '00', ':00'), '+00:00')
编辑:
select convert_tz(`date`, concat(left(substring_index(`date`, ' ', -1), 3), ':', right(substring_index(`date`, ' ', -1), 2)), '+00:00')
关于Mysql - 以UTC格式转换本地日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43470198/