我们有一个用C#编写的Windows Mobile应用程序(紧凑框架) . 区域设置为(英语)新西兰 . 时区设置为GMT 12新西兰 .
我们以GMT / UTC格式存储日期 . 我们的UTC日期为2010-02-18 18:00:00
这一次在新西兰是早上7点 .
当我们调用datetime对象时
starttime = starttime.ToLocalTime();
我们早上9点到了 .我们做错了什么?
你在那个日期时间指定了“种类”吗?像这样的东西:
DateTime parsedStartTime = DateTime.SpecifyKind( DateTime.Parse(starttime), DateTimeKind.Utc); DateTime localStartTime = parsedStartTime.DateToLocalTime();
这可能会有所帮助,因为它可能不知道您现在拥有的日期时间是Utc的类型(可能未指定) .
如果这没有帮助,可能有些代码显示您如何设置启动时间会有所帮助 .
1 回答
你在那个日期时间指定了“种类”吗?像这样的东西:
这可能会有所帮助,因为它可能不知道您现在拥有的日期时间是Utc的类型(可能未指定) .
如果这没有帮助,可能有些代码显示您如何设置启动时间会有所帮助 .