DateTime Json Return From WebAPI with Default Serializer

前端 未结 2 1876
深忆病人
深忆病人 2021-02-02 01:10

I know this question has been hashed over multiple times and I read lots of posts on that hashing but still am confused.

Using MVC4/WebAPI, I have a datetime that is sim

2条回答
  •  無奈伤痛
    2021-02-02 01:35

    if serializing with json.net keep in mind that you can specify DateTimeZoneHandling.

    Example in WebApiConf.cs

    var json = config.Formatters.JsonFormatter;
    json.SerializerSettings.DateTimeZoneHandling =Newtonsoft.Json.DateTimeZoneHandling.Local;
    

提交回复
热议问题