A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/ko/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay below:

Date.prototype.getDay() - JavaScript | MDN

Date.prototype.getDay()

Baseline Widely available

getDay() 메서드는 주어진 날짜의 현지 시간 기준 요일을 반환합니다. 0은 일요일을 나타냅니다. 현재의 일을 반환하려면 Date.prototype.getDate()를 사용하세요.

시도해 보기
const birthday = new Date("August 19, 1975 23:15:30");
const day1 = birthday.getDay();
// Sunday - Saturday : 0 - 6

console.log(day1);
// Expected output: 2
구문 반환 값

현지 시간에 따라, 주어진 날짜의 요일에 해당하는 0 이상 6 이하의 정수. (일요일은 0, 월요일은 1, 화요일은 2, ...)

예제 getDay() 사용하기

1995년 12월 25일은 월요일입니다. 따라서 아래 코드의 두 번째 명령문은 Xmas95의 값에 기반하여 weekday에 1을 할당합니다.

var Xmas95 = new Date("December 25, 1995 23:15:30");
var weekday = Xmas95.getDay();

console.log(weekday); // 1

참고: 참고: 필요하다면, 요일의 이름("월요일" 등)을 Intl.DateTimeFormat과 options 매개변수를 사용해 얻을 수 있습니다. 이 방법을 사용하면 국제화도 더 쉬워집니다.```js var options = { weekday: 'long'}; console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95)); // Monday console.log(new Intl.DateTimeFormat('ko-KR', options).format(Xmas95)); // 월요일


명세 브라우저 호환성 같이 보기

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4