问题
My sql server is located in GMT and I need to get the EST equivalent tz.
Somehow the EST is wrong.
select now(),convert_tz(now(),'GMT','EST'),convert_tz(now(),'GMT','EST') - interval 10 minute
The EST time should be 20:30 and not 19:30
Here is my results -
回答1:
As @ceejayoz mentioned, the timezones of locations change depending on daylight savings observation. In addition, it's more proper to call it UTC rather than GMT, as when you call it GMT, it connotes that your servers are tune to some local time, say, London time, and that your server's time will switch to some other time, say BST, when daylight savings is observed.
Assuming, as I presume you are trying to communicate, that your servers are set to UTC time, never observing daylight savings, and that you want to translate it to the time observed by most Eastern US cities, a solution would be
SELECT NOW(),
CONVERT_TZ(NOW(), 'UTC', 'America/New_York'),
CONVERT_TZ(NOW(), 'UTC', 'America/New_York') - INTERVAL 10 MINUTE;
来源:https://stackoverflow.com/questions/43151481/convert-gmt-time-to-est