| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since 20157.
Date getDay() 0 Date.prototype.getDate()
const birthday = new Date("August 19, 1975 23:15:30");
const day1 = birthday.getDay();
// - 0 - 6
console.log(day1);
// 2
getDay()
getDay()
const valentines = new Date("1995-02-14");
const day = valentines.getDay();
const dayNames = ["", "", "" /* , */];
console.log(dayNames[day]); // ""
options Intl.DateTimeFormat
const options = { weekday: "long" };
console.log(new Intl.DateTimeFormat("en-US", options).format(valentines));
// "Monday"
console.log(new Intl.DateTimeFormat("de-DE", options).format(valentines));
// "Montag"
weekday 1 Date xmas95 1995 12 25
const xmas95 = new Date("1995-12-25T23:15:30");
const weekday = xmas95.getDay();
console.log(weekday); // 1
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-date.prototype.getday |
This page was last modified on 202585 by MDN contributors.
DategetDate()Date.prototype.getDay()getFullYear()Date.prototype.getHours()Date.prototype.getMilliseconds()Date.prototype.getMinutes()getMonth()Date.prototype.getSeconds()Date.prototype.getTime()getTimezoneOffset()getUTCDate()getUTCDay()getUTCFullYear()Date.prototype.getUTCHours()Date.prototype.getUTCMilliseconds()Date.prototype.getUTCMinutes()getUTCMonth()Date.prototype.getUTCSeconds()getYear()setDate()setFullYear()Date.prototype.setHours()setMilliseconds()setMinutes()setMonth()setSeconds()Date.prototype.setTime()setUTCDate()setUTCFullYear()Date.prototype.setUTCHours()setUTCMilliseconds()setUTCMinutes()setUTCMonth()setUTCSeconds()setYear()toDateString()toISOString()toJSON()toLocaleDateString()toLocaleString()toLocaleTimeString()toString()toTemporalInstant()toTimeString()toUTCString()valueOf()[Symbol.toPrimitive]()Object/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |