How to make ASP.Net MVC model binder treat incoming date as UTC?

后端 未结 5 2018
感动是毒
感动是毒 2020-12-01 03:59

I\'m posting an object to an MVC controller. The object contains a field called StartDt and on the client it is a javascript Date object in local time.

When I call J

5条回答
  •  甜味超标
    2020-12-01 04:14

    Alternatively, you can specify your bound objects to be DateTimeOffset rather than DateTime, and there will be no automatic conversion. As long as the incoming string has the Z suffix, you should get the original date with an offset of +00:00.

提交回复
热议问题