Given a datetime string like so:
mystring = '2012-10-23T02:40:59Z'
I need to be able to get the day of the week (0-6) from the string.
How can I pass the above to JS so I can do something like so:
var d = new Date(mystring);
var n = d.getDay();
console.log(n)
where n returns 0-6.
Thank you
While the Date object should be able to parse the ISO 8601 format in ECMA-262, it does not work reliably across browsers so you are much better off to parse them manually:
You can then use the
getDaymethod to get the day number (Sunday = 0, Saturday = 6):