【发布时间】:2012-09-13 11:42:23
【问题描述】:
如何使用 C# 将以下格式的日期转换为印度时区 (UTC+5:30) 的日期?
2012-09-13T05:08:03.151Z
【问题讨论】:
-
这可能对你有帮助:stackoverflow.com/questions/179940/…
如何使用 C# 将以下格式的日期转换为印度时区 (UTC+5:30) 的日期?
2012-09-13T05:08:03.151Z
【问题讨论】:
怎么样
DateTime dt = DateTime.ParseExact("2012-09-13T05:08:03.151Z",
"yyyy-MM-dd HH:mm:ssK",
CultureInfo.InvariantCulture)
然后
var indianTime = TimeZoneInfo.ConvertTime (dt,
TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
【讨论】:
试试这个:
DateTime dt = DateTime.ParseExact("your current date string","your current date string format",null);
string IndianDT = dt.ToString("dd/MM/yyy");
现在在您的 IndianDT 字符串中,您将拥有所需的日期格式。
编辑:
在我上面的代码中:
将 "your current date string fromat" 替换为 "yyyy-MM-ddThh:mm:ss.fffZ"
【讨论】: