SQL 如何在 Oracle 中获取当前的 GMT

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9755999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:52:36  来源:igfitidea点击:

How to get current GMT in Oracle

sqloraclegmt

提问by user1056038

I'm trying to get the current GMT/UTC regardless of the time zones my current database is located. The possible solution I found is:

无论我当前的数据库位于哪个时区,我都试图获取当前的 GMT/UTC。我找到的可能解决方案是:

SELECT SYSTIMESTAMP AT TIME ZONE dbtimezone FROM DUAL;

and it is giving me the current GMT, but I am not 100% confident if this is the right way. Would anyone please help provide the best way to get the current GMT? Thanks.

它给了我当前的格林威治标准时间,但我不是 100% 相信这是正确的方法。有人可以帮忙提供获得当前格林威治标准时间的最佳方式吗?谢谢。

回答by Justin Cave

If you want the current time in GMT, you'd want

如果你想要格林威治标准时间的当前时间,你会想要

SELECT systimestamp AT TIME ZONE 'GMT'
  FROM dual

That will work regardless of the dbtimezone.

无论dbtimezone.