Parsing a Auto-Generated .NET Date Object with Javascript/JQuery

The link from Robert is good, but we should strive to answer the question here, not to just post links.

Here’s a quick function that does what you need. http://jsfiddle.net/Aaa6r/

function deserializeDotNetDate(dateStr) {
  var matches = /\/Date\((\d*)\)\//.exec(dateStr);

  if(!matches) {
    return null;
  }

  return new Date( parseInt( matches[1] ) );
}

deserializeDotNetDate("/Date(1304146800000)/");

Leave a Comment