如何从UTC时间获取MySQL中的Unix时间戳? [英] How to get Unix timestamp in MySQL from UTC time?
本文介绍了如何从UTC时间获取MySQL中的Unix时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我执行 unix_timestamp(some_date)
,它将内部将 some_date
转换为UTC,而 some_date
已经在UTC。有没有办法获取当前的Unix时间戳?
If I do unix_timestamp(some_date)
, it internally converts some_date
to UTC, whereas some_date
is already in UTC. Is there any way to get the current Unix timestamp?
编辑:我需要UTC时间的Unix时间戳。
I need Unix timestamp from UTC time.
推荐答案
您应该可以使用 CONVERT_TZ
:
You should be able to convert it from UTC to the local timezone first using CONVERT_TZ
:
UNIX_TIMESTAMP(CONVERT_TZ(some_date, '+00:00', @@global.time_zone))
另请参见: 10.6。 MySQL服务器时区支持
这篇关于如何从UTC时间获取MySQL中的Unix时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文