How can I convert that date format /Date(1302589032000+0400)/
to JS Date object?
Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.
Deserializes the JSON to the specified . NET type. Deserializes the JSON to the specified . NET type using a collection of JsonConverter.
SerializeObject Method (Object, Type, JsonSerializerSettings) Serializes the specified object to a JSON string using a type, formatting and JsonSerializerSettings. Namespace: Newtonsoft.Json.
The ISerializable interface implies a constructor with the signature constructor (SerializationInfo information, StreamingContext context) . At deserialization time, the current constructor is called only after the data in the SerializationInfo has been deserialized by the formatter.
Remove the text first:
var src = "/Date(1302589032000+0400)/";
//Remove all non-numeric (except the plus)
src = src.replace(/[^0-9 +]/g, '');
//Create date
var myDate = new Date(parseInt(src));
Here's a workding jsFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With