Date.prototype
속성은 Date
생성자의 프로토타입을 나타냅니다.
Property attributes of Date.prototype |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | yes |
설명
JavaScript Date
인스턴스는 Date.prototype
을 상속합니다. 생성자의 프로토타입을 변경해 모든 Date
인스턴스의 속성과 메서드를 수정할 수 있습니다.
2000년대 달력과의 호환성을 위해 연도는 언제나 완전하게 네 자리 숫자로 작성해야 합니다. 즉 98 대신 1998이 올바른 작성법입니다. Date
는 완전한 연도 설정에 도움이 될 getFullYear()
, setFullYear()
, getUTCFullYear()
, setUTCFullYear()
메서드를 가지고 있습니다.
ECMAScript 6부터 Date.prototype
은 Date
인스턴스가 아닌 평범한 객체입니다.
속성
Date.prototype.constructor
- 인스턴스 생성에 사용한 생성자를 반환합니다. 기본값은
Date
입니다.
메서드
접근자
Date.prototype.getDate()
- 주어진 날짜의 일(1-31)을 현지 시간에 맞춰 반환합니다.
Date.prototype.getDay()
- 주어진 날짜의 요일(0-6)을 현지 시간에 맞춰 반환합니다.
Date.prototype.getFullYear()
- 주어진 날짜의 연도(4자리 수)를 현지 시간에 맞춰 반환합니다.
Date.prototype.getHours()
- 주어진 날짜의 시(0-23)를 현지 시간에 맞춰 반환합니다.
Date.prototype.getMilliseconds()
- 주어진 날짜의 밀리초(0-999)를 현지 시간에 맞춰 반환합니다.
Date.prototype.getMinutes()
- 주어진 날짜의 분(0-59)을 현지 시간에 맞춰 반환합니다.
Date.prototype.getMonth()
- 주어진 날짜의 월(0-11)을 현지 시간에 맞춰 반환합니다.
Date.prototype.getSeconds()
- 주어진 날짜의 초(0-59)를 현지 시간에 맞춰 반환합니다.
Date.prototype.getTime()
- 주어진 날짜와 1970년 1월 1일 0시 0분(UTC)의 차이를 밀리초로 반환합니다.
Date.prototype.getTimezoneOffset()
- 현재 로케일의 시간대 차이를 분으로 환산해 반환합니다.
Date.prototype.getUTCDate()
- 주어진 날짜의 일(1-31)을 UTC에 맞춰 반환합니다.
Date.prototype.getUTCDay()
- 주어진 날짜의 요일(0-6)을 UTC에 맞춰 반환합니다.
Date.prototype.getUTCFullYear()
- 주어진 날짜의 연도(4자리 수)를 UTC에 맞춰 반환합니다.
Date.prototype.getUTCHours()
- 주어진 날짜의 시(0-23)를 UTC에 맞춰 반환합니다.
Date.prototype.getUTCMilliseconds()
- 주어진 날짜의 밀리초(0-999)를 UTC에 맞춰 반환합니다.
Date.prototype.getUTCMinutes()
- 주어진 날짜의 분(0-59)을 UTC에 맞춰 반환합니다.
Date.prototype.getUTCMonth()
- 주어진 날짜의 월(0-11)을 UTC에 맞춰 반환합니다.
Date.prototype.getUTCSeconds()
- 주어진 날짜의 초(0-59)를 UTC에 맞춰 반환합니다.
Date.prototype.getYear()
- 주어진 날짜의 연도(주로 두세자리 숫자)를 현지 시간에 맞춰 반환합니다.
getFullYear()
를 사용하세요.
설정자
Date.prototype.setDate()
- Sets the day of the month for a specified date according to local time.
Date.prototype.setFullYear()
- Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to local time.
Date.prototype.setHours()
- Sets the hours for a specified date according to local time.
Date.prototype.setMilliseconds()
- Sets the milliseconds for a specified date according to local time.
Date.prototype.setMinutes()
- Sets the minutes for a specified date according to local time.
Date.prototype.setMonth()
- Sets the month for a specified date according to local time.
Date.prototype.setSeconds()
- Sets the seconds for a specified date according to local time.
Date.prototype.setTime()
- Sets the
Date
object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC, allowing for negative numbers for times prior. Date.prototype.setUTCDate()
- Sets the day of the month for a specified date according to universal time.
Date.prototype.setUTCFullYear()
- Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to universal time.
Date.prototype.setUTCHours()
- Sets the hour for a specified date according to universal time.
Date.prototype.setUTCMilliseconds()
- Sets the milliseconds for a specified date according to universal time.
Date.prototype.setUTCMinutes()
- Sets the minutes for a specified date according to universal time.
Date.prototype.setUTCMonth()
- Sets the month for a specified date according to universal time.
Date.prototype.setUTCSeconds()
- Sets the seconds for a specified date according to universal time.
Date.prototype.setYear()
- Sets the year (usually 2-3 digits) for a specified date according to local time. Use
setFullYear()
instead.
변환 접근자
Date.prototype.toDateString()
- Returns the "date" portion of the
Date
as a human-readable string like 'Thu Apr 12 2018' Date.prototype.toISOString()
- Converts a date to a string following the ISO 8601 Extended Format.
Date.prototype.toJSON()
- Returns a string representing the
Date
usingtoISOString()
. Intended for use byJSON.stringify()
. Date.prototype.toGMTString()
- Returns a string representing the
Date
based on the GMT (UT) time zone. UsetoUTCString()
instead. Date.prototype.toLocaleDateString()
- Returns a string with a locality sensitive representation of the date portion of this date based on system settings.
Date.prototype.toLocaleFormat()
- Converts a date to a string, using a format string.
Date.prototype.toLocaleString()
- Returns a string with a locality sensitive representation of this date. Overrides the
Object.prototype.toLocaleString()
method. Date.prototype.toLocaleTimeString()
- Returns a string with a locality sensitive representation of the time portion of this date based on system settings.
Date.prototype.toSource()
- Returns a string representing the source for an equivalent
Date
object; you can use this value to create a new object. Overrides theObject.prototype.toSource()
method. Date.prototype.toString()
- Returns a string representing the specified
Date
object. Overrides theObject.prototype.toString()
method. Date.prototype.toTimeString()
- Returns the "time" portion of the
Date
as a human-readable string. Date.prototype.toUTCString()
- Converts a date to a string using the UTC timezone.
Date.prototype.valueOf()
- Returns the primitive value of a
Date
object. Overrides theObject.prototype.valueOf()
method.
명세
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.1. |
ECMAScript 5.1 (ECMA-262) The definition of 'Date.prototype' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Date.prototype' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Date.prototype' in that specification. |
Living Standard |
브라우저 호환성
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.
No compatibility data found. Please contribute data for "javascript.builtins.Date.prototype" (depth: 1) to the MDN compatibility data repository.