How to pass a datetime parameter?

后端 未结 10 1693
暗喜
暗喜 2020-11-29 01:56

How to pass UTC dates to Web API?

Passing 2010-01-01 works fine, but when I pass a UTC date such as 2014-12-31T22:00:00.000Z (with a time c

10条回答
  •  时光取名叫无心
    2020-11-29 02:41

    As a similar alternative to s k's answer, I am able to pass a date formatted by Date.prototype.toISOString() in the query string. This is the standard ISO 8601 format, and it is accepted by .Net Web API controllers without any additional configuration of the route or action.

    e.g.

    var dateString = dateObject.toISOString(); // "2019-07-01T04:00:00.000Z"
    

提交回复
热议问题