convert GMT time to EST

主宰稳场 提交于 2021-02-08 07:54:39

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!