.net 如何使用DateTime对象从UTC时间获取特定时区的月数?

.net 如何使用DateTime对象从UTC时间获取特定时区的月数?,.net,.net-core,.net,.net Core,我在DateTime对象中存储了UTC格式的EST时区的年末(2017年12月31日)。当我得到Month属性时,它是1,因为它存储在UTC中,当转换UTC为2018年1月1日04:59:59时,它在EST中的年底 如何使用美国/纽约时区将该日期转换为正确的时区,以获得该时区的正确月号?我最终使用野田佳彦来处理转换 using NodaTime; //Get the correct timezone DateTimeZone zone = DateTimeZoneProviders.Tzdb [

我在DateTime对象中存储了UTC格式的EST时区的年末(2017年12月31日)。当我得到Month属性时,它是1,因为它存储在UTC中,当转换UTC为2018年1月1日04:59:59时,它在EST中的年底


如何使用美国/纽约时区将该日期转换为正确的时区,以获得该时区的正确月号?

我最终使用野田佳彦来处理转换

using NodaTime;
//Get the correct timezone
DateTimeZone zone = DateTimeZoneProviders.Tzdb ["America/New_York"];
//Convert to the correct month
var month = Instant.FromDateTimeUtc(endOfYear.ToUniversalTime()).InZone(zone.Month);
Console.Write(endOfYear.Month); //1 Not expected value
Console.Write(month); // 12 expected value