我知道对此有很多问题,但我仍然感到困惑!
如何从 UTC 转换为 EDT。即到美国东部标准时间(特别是纽约)但有夏令时?
我正在尝试这个:
TimeZoneInfo edtZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime utcDT = UnixTimeStampToDateTime(double.Parse(fields[0]));
utcDT.Kind = DateTimeKind.Utc; //THIS LINE IS WRONG
DateTime edtDT = TimeZoneInfo.ConvertTimeFromUtc(utcDT, edtZone);
//Put in for as requested
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
{
// Unix timestamp is seconds past epoch
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dtDateTime;
}
谢谢