Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json Datetime issue [duplicate]

Possible Duplicate:
how to force netwtonsoft json serializer to serialize datetime property to string?

I am using Newtonsoft.Json to convert my object in to JSON file. But I am having issue with the DateTime, in my object datetime field is set as "7/30/2012 8:29:12 PM" but in JSON file. I am getting DateTime field in this format:

"\/Date(1343660352227+0530)\/".

I need to get the DateTime in the same format as that of the object. Is it possible? What should I do in order to get the same format?

like image 218
Amol Kolekar Avatar asked Aug 01 '12 10:08

Amol Kolekar


1 Answers

I got the solution as follow.

JsonConvert.SerializeObject(this, Formatting.None, new IsoDateTimeConverter() {
    DateTimeFormat = "yyyy-MM-dd hh:mm:ss"
});

Here is the answer:

how to force netwtonsoft json serializer to serialize datetime property to string?

like image 169
Amol Kolekar Avatar answered Oct 25 '22 07:10

Amol Kolekar