getHours()
메서드는 주어진 날짜의 현지 시간 기준 시를 반환합니다.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
구문
dateObj.getHours()
반환 값
주어진 날짜의 현지 시간 기준 시를 나타내는 0에서 23 사이의 정수.
예제
getHours()
사용하기
아래의 두 번째 명령문은 Date
객체 Xmas95
날짜의 시를 hours
변수에 할당합니다.
var Xmas95 = new Date('December 25, 1995 23:15:30');
var hours = Xmas95.getHours();
console.log(hours); // 23
명세
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) The definition of 'Date.prototype.getHours' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Date.prototype.getHours' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Date.prototype.getHours' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.