I am calling an API controller post
method from client with a model that contains datetime properties, but when the request is received at the API controller, the datetime value automatically get changed.
My client application is a desktop application and running under the Indian timezone and API is hosted on a server that is in the EST timezone.
When my client application sends
"TransDate": "2023-03-26T00:00:00+05:30"
it is changed to
"TransDate":"2023-03-25T14:30:00-04:00"
in the API controller.
My client desktop application can run under multiple time zones and the datetime value sent from client location is in the local time zone that should be unchanged when it receives to at API controller.
One alternative I can think of to change DateTime
type to DatetimeOffSet
but problem is: I have to change code in multiple places as it exists throughout the application, I am looking for any common solution to prevent this conversion.