> var maybeDateString = "/Date(1346713200000+0100)/";
> fromDateString(maybeDateString)
Tue Sep 04 2012 02:00:00 GMT+0200
function fromDateString(str) {
var res = str.match(/\/Date\((\d+)(?:([+-])(\d\d)(\d\d))?\)\//);
if (res == null)
return new Date(NaN); // or something that indicates it was not a DateString
var time = parseInt(res[1], 10);
if (res[2] && res[3] && res[4]) {
var dir = res[2] == "+" ? -1 : 1,
h = parseInt(res[3], 10),
m = parseInt(res[4], 10);
time += dir * (h*60+m) * 60000;
}
return new Date(time);
}