The getUTCDay() method returns the day of the week ranged from 0 to 6 for the date object, according to universal time.
The getUTCDay() method returns the day of the week ranged from 0 to 6 for the date object, according to universal time.
Sunday is 0, Monday is 1, and so on.
UTC time is the same as GMT time.
Date.getUTCDay()
None
A Number, from 0 to 6, representing the day of the week
Return the day of the week, according to universal time:
//display the day of the week, according to UTC. var d = new Date(); var n = d.getUTCDay(); console.log(n);/*from w ww .j a va2s.c o m*/ //Note: 0=Sunday, 1=Monday, etc. //Return the name of the weekday (not just a number): //display the day of the week, according to UTC. var d = new Date(); var weekday = new Array(7); weekday[0] = "Sunday"; weekday[1] = "Monday"; weekday[2] = "Tuesday"; weekday[3] = "Wednesday"; weekday[4] = "Thursday"; weekday[5] = "Friday"; weekday[6] = "Saturday"; var n = weekday[d.getUTCDay()]; console.log(n);