ASP.NET MVC JsonResult Date Format

前端 未结 25 3288
渐次进展
渐次进展 2020-11-21 11:22

I have a controller action that effectively simply returns a JsonResult of my model. So, in my method I have something like the following:

return new JsonRes         


        
25条回答
  •  死守一世寂寞
    2020-11-21 11:40

    Using jQuery to auto-convert dates with $.parseJSON

    Note: this answer provides a jQuery extension that adds automatic ISO and .net date format support.

    Since you're using Asp.net MVC I suspect you're using jQuery on the client side. I suggest you read this blog post that has code how to use $.parseJSON to automatically convert dates for you.

    Code supports Asp.net formatted dates like the ones you mentioned as well as ISO formatted dates. All dates will be automatically formatted for you by using $.parseJSON().

提交回复
热议问题