I'm getting dates back from a webservice, and they look like this:
/Date(1310187160270+1200)/
How would I go about converting this to a date object in javascript?
I've googled around a bit and cannot find a decent answer - this may be in part due to the fact that I'm not exactly sure what this type of date object is called - so if someone could shed light on that also, that would be appreciated.
var date = new Date(1310187160270+1200);
console.log(date)
returns
Sat Jul 09 2011 06:52:41 GMT+0200 (South Africa Standard Time)
If you need to strip it as is in Question:
var returnVariable = "/Date(1346713200000+0100)/";
var d = new Date(parseFloat(returnVariable.replace("/Date(", "").replace(")/", "")));
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