-3

I have an object model that contains DateTime property. This object is being serialized into Json format by calling

return Json(model);

as a result, I am getting this string

"/Date(1474398517910)/"

instead of DateTime. That's because Json doesnt support DateTime format, instead it uses a string.

Question - how to make this string to look like real date, something like

"2016-10-22 12:20 PM"

Thanks?

monstro
  • 6,254
  • 10
  • 65
  • 111
  • Use json.net instead of the default serializer. See [Setting the Default JSON Serializer in ASP.NET MVC](http://stackoverflow.com/q/14591750/1260204). Also you want to use ISO8601 for your DateTime instance (which is what json.net will do). – Igor Sep 20 '16 at 19:19
  • change `DateFormatHandling.MicrosoftDateFormat` to `DateFormatHandling.IsoDateFormat` see http://stackoverflow.com/a/34592117/932418 – L.B Sep 20 '16 at 19:20

1 Answers1

-1

Try this

DataTime obj= new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize>(jsonString);
DespeiL
  • 993
  • 9
  • 28