Date.prototype.getHours()

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

구문

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  

브라우저 호환성

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
getHoursChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100

Legend

Full support  
Full support

같이 보기