I have been searching around for how to convert from UTC to mountain time and I have successfully found the following function that everyone says takes into account DST. Whenever it converts from UTC to Mountain it’s always -7 for the offset (when it should be -6 currently). Except it doesn’t seem to be. Can anyone shine some light on this for me or a way to make it take into account DST?
DateTime utcTime = new DateTime(createdDate.Ticks, DateTimeKind.Utc);
DateTime mountainTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(utcTime, "US Mountain Standard Time");
Thanks,
Dman
It looks like there are two zones in .NET (at least on my Windows 8 installation) which are mountain time.
There’s “US Mountain Standard Time” which you’re using, and which doesn’t observe DST (it’s for Arizona) – and plain “Mountain Standard Time” which does observe DST. So you just need to get rid of the “US ” part and it will work:
Output (UK culture):