How to convert time between timezones (UTC to EDT)?

后端 未结 4 1107
暗喜
暗喜 2020-12-17 16:37

I need to have a common function to convert UTC time to EDT. I have a server in India. An application in it needs to use EDT time for all time purposes.

I am using

4条回答
  •  太阳男子
    2020-12-17 16:52

    The cowboy method is to take the UTC time, subtract four hours' worth of seconds from it (the timezone offset), format it using a UTC formatting function, and slap a "EDT" label on it.

    If you need to use Daylight Time sometimes and Standard Time other times, either make a lookup table of switchover dates, or use some calendar function.

提交回复
热议问题