我尝试将特定UTC时间转换为IST时间。但我得到了相同的约会。
// utcdate是6/15/2014 12:00:00 AM
var istdate = TimeZoneInfo.ConvertTimeFromUtc(utcdate,
TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
输出:6/15/2014 12:00:00 AM
你能指导我解决这个问题吗?
答案 0 :(得分:11)
试试这个:
DateTime utcdate = DateTime.ParseExact("6/15/2014 12:00:00 AM", "M/dd/yyyy
h:mm:ss tt",CultureInfo.InvariantCulture);
var istdate = TimeZoneInfo.ConvertTimeFromUtc(utcdate,
TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
我收到了输出:
6/15/2014 5:30:00 AM
答案 1 :(得分:2)
您也可以尝试:
DateTime utc = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2014, 6, 16, 2, 0, 0));
DateTime temp = new DateTime(utc.Ticks, DateTimeKind.Utc);
DateTime ist = TimeZoneInfo.ConvertTimeFromUtc(temp, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));