C# Datetimes: Conversion for different time zones

前端 未结 6 779
[愿得一人]
[愿得一人] 2020-12-01 19:06

I have a bunch of date times that I keep track of for my app. They are all in UTC time. For part of my app I want to send an email with one of these times, but edited to be

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 19:56

    Use the TimeZoneInfo Class to convert a local time to a time in an alternative timezone:

    TimeZoneInfo est = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
    DateTime targetTime = TimeZoneInfo.ConvertTime(timeToConvert, est);
    

提交回复
热议问题