views:

294

answers:

2

I'm getting datetime in JSON format as -

"\/Date(1261413600000+0530)\/"

From code behind, I'm using DataContractJsonSerializer.ReadObject method to deserialize data.

Converted data time is not correct.

How to parse correct JSON date time from code behind?

A: 

You can use a regular expression to get the number which is the number of ticks since 1/1/1970. Then you can get the date using the following:

DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
DateTime dt = unixEpoch.AddSeconds(Convert.ToDouble(ticks));
Ben Griswold
+1  A: 

Have you seen this article on Encosia?

CResults