Get the weekday:
const d = new Date();
let day = d.getUTCDay();
Try it Yourself »
Get the name of the weekday (not just a number):
const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
const d = new Date();
let day = weekday[d.getUTCDay()];
Try it Yourself »
getUTCDay()
returns the day of the week (0 to 6) of a date.
getUTCDay()
returns the day of the week according to universal time.
Sunday = 0, Monday = 1, ... (See below):
UTC (Universal Time Coordinated) is the time set by the World Time Standard.
UTC time is the same as GMT time (Greenwich Mean Time).
All JavaScript getUTC methods assume that the date is of local time.
Date.getUTCDay()
NONE |
Type | Description |
A number | The weekday of a date (0 to 6), according to UTC. |
getUTCDay()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!