Question: > 
> **Possible Duplicate:**  
> 
> [Format a Microsoft JSON date?](https://stackoverflow.com/questions/206384)
> 
> 
> 

The ASP.NET function `Json()` formats and returns a date as

```
{"d":"\/Date(1240718400000)\/"}

```

which has to be dealt with on the client side which is problematic. What are your suggestions for approaches to sending date values back and forth?

Answer: 
If you are not tied to the MS JSON serializer you could use [Json.NET](http://www.codeplex.com/Json). It comes with an IsoDateTimeConverter to handle issues with serializing dates. This will serialize dates into an [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601) formatted string. 

For instance, in our project serializing `myObject` is handled via the following code.

```
JsonNetResult jsonNetResult = new JsonNetResult();
jsonNetResult.Formatting = Formatting.Indented;
jsonNetResult.SerializerSettings.Converters.Add(new IsoDateTimeConverter());
jsonNetResult.Data = myObject;

```

If you decide to take the Json.NET plunge you'll also want to grab [JsonNetResult](http://james.newtonking.com/archive/2008/10/16/asp-net-mvc-and-json-net.aspx) as it returns an ActionResult that can be used in ASP.NET MVC application. It's quite easy to use.

For more info see: [Good (Date)Times with Json.NET](http://james.newtonking.com/archive/2009/02/20/good-date-times-with-json-net.aspx)
It may be ugly, but it works:

```
 var epoch = (new RegExp('/Date\\((-?[0-9]+)\\)/')).exec(d);
 $("#field").text((new Date(parseInt(epoch[1]))).toDateString());

```

Probably, it is not necessary to match the whole string, and just (-?[0-9]+) is enough...