--- title: Date.prototype.getHours() slug: Web/JavaScript/Reference/Global_Objects/Date/getHours tags: - Date - JavaScript - Method - Prototype - Reference translation_of: Web/JavaScript/Reference/Global_Objects/Date/getHours ---
getHours()
메서드는 주어진 날짜의 현지 시간 기준 시를 반환합니다.
dateObj.getHours()
주어진 날짜의 현지 시간 기준 시를 나타내는 0에서 23 사이의 정수.
getHours()
사용하기아래의 두 번째 명령문은 {{jsxref("Date")}} 객체 Xmas95
날짜의 시를 hours
변수에 할당합니다.
var Xmas95 = new Date('December 25, 1995 23:15:30'); var hours = Xmas95.getHours(); console.log(hours); // 23
Specification | Status | Comment |
---|---|---|
{{SpecName('ES1')}} | {{Spec2('ES1')}} | Initial definition. Implemented in JavaScript 1.0. |
{{SpecName('ES5.1', '#sec-15.9.5.18', 'Date.prototype.getHours')}} | {{Spec2('ES5.1')}} | |
{{SpecName('ES6', '#sec-date.prototype.gethours', 'Date.prototype.getHours')}} | {{Spec2('ES6')}} | |
{{SpecName('ESDraft', '#sec-date.prototype.gethours', 'Date.prototype.getHours')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.Date.getHours")}}