1 year ago

#298812

test-img

Jerry

DateTime is changing when passed to Cloud

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?

c#

datetime

asp.net-web-api

datetimeoffset

0 Answers

Your Answer

Accepted video resources