我想转换这种格式:
2012-08-09T07:48:16+02:00
2012-01-17T17:49:05+01:00
2012-01-17T17:49:05-05:00
到“dd.MM.yyyy
”的时区 UTC + 02:00
答案 0 :(得分:4)
检查方式:
var dt = DateTime.Parse("2012-08-09T07:48:16+02:00");
var newDt = TimeZoneInfo.ConvertTime(dt, TimeZoneInfo.FindSystemTimeZoneById("FLE Standard Time"));
Console.WriteLine(newDt.ToString("dd.MM.yyyy"));
顺便说一句,UTC+02:00
它不是时区的名称,实时将取决于国家/地区和夏令时规则。
答案 1 :(得分:3)
试试这种方式
TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "New Zealand Standard Time", "UTC")
更多讨论:
How to convert DateTime in Specific timezone?
http://blog.mozilla.org/it/2012/11/16/converting-timezone-specific-times-in-mysql/