I'd go about this another way. Gaby explained about parseInt, but a note of caution: parseInt
interprets integers with leading zeroes as octals. This might not apply in your case, but IMO, this is a safer approach:
var date = new Date(+('/Date(1224043200000)/'.match(/\d+/)[0]));
First, '/Date(1224043200000)/'.match(/\d+/)
extracts the numbers from the string, in an array: ["1224043200000"]
.
We then need the first element of these matches, hence the [0]
.
To be on the safe side, I wrapped all this in brackets, preceded by a +
sign, to coerce the matched substring to a number: +('/Date(1224043200000)/'.match(/\d+/)[0]) === 1224043200000
This is passed to the Date
constructor, which creates a date object with "Wed Oct 15 2008 06:00:00 GMT+0200 (Romance Daylight Time)"
as a string value
To catch any possible errors, you might want to split this one-liner up a bit, but that's up to you :)