传递到云时日期时间发生变化
我们有一个 VueJS 应用程序,它将 JSON 对象传递回 WebAPI。 WebApi 位于云中的虚拟机上。
该 JSON 对象将具有日期时间属性以及其他属性。
在 WebApi 中,此日期时间在类 (MyClass.cs) 中定义为:
public DateTimeOffset MyDate { get; set; }
如果我的示例中传递的日期时间的值 =“2022-03-15 09:00”。我希望 WebApi 不改变该值。
当在我的本地开发 PC 上运行 WebApi 时,这在存储到数据库时有效:“MyObject.MyDate.LocalDateTime”
但是,当将对象发送到云中的 WebApi 时,这会使用偏移量(-4)和调整日期时间增加4小时。日期时间存储为“2022-03-15 13:00”
我的电脑和云虚拟机均采用东部时间(UTC-4)。
为什么有区别?
如何阻止 WebApi 更改传递给它的日期时间?
We have a VueJS app that is passing a JSON object back to the WebAPi. The WebApi is sitting on a VM in the cloud.
This JSON object will have a datetime property, along with other properties.
In the WebApi, this datetime is defined in a class (MyClass.cs) as:
public DateTimeOffset MyDate { get; set; }
If the value of the passed datetime in my example = "2022-03-15 09:00". I would like to have the WebApi not change the value.
When running the WebApi on my local dev PC, this works when stored to the DB: "MyObject.MyDate.LocalDateTime"
However, when sending the object to the WebApi in the cloud, this adjust the datetime using the offset(-4) and adds 4 hours. The datetime is stored as "2022-03-15 13:00"
My PC and the cloud VM are both on Eastern Time(UTC-4).
Why the difference?
How do I stop the WebApi from changing the DateTime that is passed to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论