Convert a JSON date string to a javascript date object

JSON formats strings in the format;

\/Date(1336543200000-0600)\/|>



which cannot be directly parsed into a javascript date object using new Date

Related tags: JavaScript

Credit: Original Poster

The following function can be used:

function ConvertJSONDateToDate(jsonDate) {
    var dateSlice = jsonDate.slice(6, 24);
    var milliseconds = parseInt(dateSlice);
    var date = new Date(milliseconds);

    return date;
}

Rating: 2

Propose a different solution...