In MySQL caculating offset for a time zone

后端 未结 8 1777
死守一世寂寞
死守一世寂寞 2020-12-08 22:22

Is there a way in MySQL to calculate the offset for any timezone? For example, to get the local time in the timezone Asia/calcutta. What I want to do is calcula

8条回答
  •  执笔经年
    2020-12-08 22:42

    The offset will depend on the time that you're interested in - for instance, I'd currently have an offset of one hour from UTC, but during the winter my offset would be zero.

    Judging by the docs page on MySQL time zone support, you want to use the convert_tz function. If you're trying to convert UTC to local time, pass in "Etc/GMT+0" as the "from" time zone, and "Asia/Calcutta" as the "to".

提交回复
热议问题