--- title: Date.prototype.getDate() slug: Web/JavaScript/Reference/Global_Objects/Date/getDate tags: - Date - JavaScript - Method - Prototype - Reference translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate ---
{{JSRef}}

getDate() 메서드는 주어진 날짜의 현지 시간 기준 일을 반환합니다.

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

구문

dateObj.getDate()

반환 값

현지 시간에 따라, 주어진 날짜의 일에 해당하는 1 이상 31 이하의 정수.

예제

getDate() 사용하기

아래 코드의 두 번째 명령문은 Xmas95의 값에 기반하여 day에 2를 할당합니다.

var Xmas95 = new Date('December 25, 1995 23:15:30');
var day = Xmas95.getDate();

console.log(day); // 25

명세

Specification Status Comment
{{SpecName('ESDraft', '#sec-date.prototype.getdate', 'Date.prototype.getDate')}} {{Spec2('ESDraft')}}  
{{SpecName('ES6', '#sec-date.prototype.getdate', 'Date.prototype.getDate')}} {{Spec2('ES6')}}  
{{SpecName('ES5.1', '#sec-15.9.5.14', 'Date.prototype.getDate')}} {{Spec2('ES5.1')}}  
{{SpecName('ES1')}} {{Spec2('ES1')}} Initial definition. Implemented in JavaScript 1.1.

브라우저 호환성

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

같이 보기