Azure表存储错误地插入日期属性

Dav*_*New 3 c# datetime azure azure-storage azure-table-storage

为什么我必须创建我的实体DateTime属性DateTimeKind.Local

例如,我需要在将其插入到表中之前设置以下属性:

someObject.DatePerformed = new DateTime(2012, 11, 19, 3, 3, 3, DateTimeKind.Local);
Run Code Online (Sandbox Code Playgroud)

如果我没有指定DateTimeKind则保存不正确(添加2小时).这在我的本地存储模拟器和我的Azure帐户上都会发生.我在GMT +2小时从我的本地机器运行客户端应用程序.

goo*_*ate 6

这不是Azure问题,这是DateTime的工作方式.您需要指定对象的时区DateTime.

为避免用户处于不同时区时出现问题,我建议将所有内容存储在UTC中,然后在运行时将其解析为本地时间.

否则,在手动转换时区时,您将面临问题.