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

后端 未结 4 1101
暗喜
暗喜 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:55

    TimeZoneInfo.ConvertTimeFromUtc will have correct offset depending on the DateTime you give it. For example:

    3AM UTC/11PM ET (4 hour offset):

    DateTime timeSummerET = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime("08/01/2019 03:00:00"), zoneET);
    

    3AM UTC/10PM ET (5 hour offset):

    DateTime timeWinterET = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime("12/01/2019 03:00:00"), zoneET);
    

提交回复
热议问题