简体   繁体   English

MySQL获取特定时区的时间

[英]MySQL get time of a specific timezone

I need to get the time of a specific timezone using MySQL. 我需要使用MySQL获取特定时区的时间。

I tried using CONVERT_TZ , but it takes 3 arguments, is there any other MySQL function which will return time instead of converting time from one timezone to another? 我尝试使用CONVERT_TZ ,但是它CONVERT_TZ 3个参数,是否还有其他MySQL函数将返回时间,而不是将时间从一个时区转换为另一个时区?

Either of these will work: 这些都可以工作:

Option 1: 选项1:

SET time_zone = 'America/New_York';
SELECT NOW();

Option 2: 选项2:

SELECT CONVERT_TZ(UTC_TIMESTAMP(),'UTC','America/New_York');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM