From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../global_objects/date/getmonth/index.html | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/date/getmonth/index.html (limited to 'files/ko/web/javascript/reference/global_objects/date/getmonth/index.html') diff --git a/files/ko/web/javascript/reference/global_objects/date/getmonth/index.html b/files/ko/web/javascript/reference/global_objects/date/getmonth/index.html new file mode 100644 index 0000000000..48fe002a99 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/date/getmonth/index.html @@ -0,0 +1,94 @@ +--- +title: Date.prototype.getMonth() +slug: Web/JavaScript/Reference/Global_Objects/Date/getMonth +tags: + - Date + - JavaScript + - Method + - Prototype + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMonth +--- +
{{JSRef}}
+ +

getMonth() 메서드는 Date 객체의 월 값을 현지 시간에 맞춰 반환합니다. 월은 0부터 시작합니다.

+ +
{{EmbedInteractiveExample("pages/js/date-getmonth.html")}}
+ + + +

구문

+ +
dateObj.getMonth()
+ +

반환 값

+ +

현지 시간 기준 월을 나타내는 0에서 11 사이의 정수. 0은 1월, 1은 2월... 을 나타냅니다.

+ +

예제

+ +

getMonth() 사용하기

+ +

다음 예제는 {{jsxref("Date")}} 객체 Xmas95의 값을 사용해 변수 month에 11을 할당합니다.

+ +
var Xmas95 = new Date('December 25, 1995 23:15:30');
+var month = Xmas95.getMonth();
+
+console.log(month); // 11
+
+ +
+

참고: 필요한 경우 {{jsxref("DateTimeFormat", "Intl.DateTimeFormat()")}}과 options 매개변수를 사용해 해당하는 달의 이름("January" 등)을 가져올 수 있습니다. 이 방법을 사용하면 국제화도 보다 편리합니다.

+ +
var options = { month: 'long'};
+console.log(new Intl.DateTimeFormat('ko-KR', options).format(Xmas95));
+// 12월
+console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95));
+// December
+
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.9.5.12', 'Date.prototype.getMonth')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-date.prototype.getmonth', 'Date.prototype.getMonth')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-date.prototype.getmonth', 'Date.prototype.getMonth')}}{{Spec2('ESDraft')}}
+ +

브라우저 호환성

+ + + +

{{Compat("javascript.builtins.Date.getMonth")}}

+ +

같이 보기

+ + -- cgit v1.2.3-54-g00ecf