ASP.NET MVC JsonResult Date Format

前端 未结 25 3331
渐次进展
渐次进展 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:57

    I had a number of issues come up with JSON dates and decided to just get rid of the problem by addressing the date issue in the SQL. Change the date format to a string format

    select flddate from tblName
    
    select flddate, convert(varchar(12), flddate, 113) as fldDateStr from tblName
    

    By using the fldDateStr the problem dissappeared and I could still use the date field for sorting or other purposes.

提交回复
热议问题