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

getSeconds() 메서드는 Date 객체의 초 값을 현지 시간에 맞춰 반환합니다.

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

구문

dateObj.getSeconds()

반환 값

현지 시간 기준 초를 나타내는 0에서 59 사이의 정수.

예제

getSeconds() 사용하기

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

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

console.log(seconds); // 30

명세

Specification Status Comment
{{SpecName('ES1')}} {{Spec2('ES1')}} Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.9.5.22', 'Date.prototype.getSeconds')}} {{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-date.prototype.getseconds', 'Date.prototype.getSeconds')}} {{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-date.prototype.getseconds', 'Date.prototype.getSeconds')}} {{Spec2('ESDraft')}}

브라우저 호환성

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

같이 보기