The Date.prototype
property represents the prototype for the Date
constructor.
Property attributes of Date.prototype
| |
---|---|
Writable | no |
Enumerable | no |
Configurable | yes |
JavaScript Date
instances inherit from Date.prototype
. You can modify the constructor's prototype object to affect properties and methods inherited by JavaScript Date
instances.
For compatibility with millennium calculations (in other words, to take into account the year 2000), you should always specify the year in full; for example, use 1998, not 98. To assist you in specifying the complete year, JavaScript includes the methods getFullYear()
, setFullYear()
, getUTCFullYear()
and setUTCFullYear()
.
Starting with ECMAScript 6, the Date.prototype
object is itself an ordinary object. It is not a Date
instance.
Date.prototype.constructor
Date
constructor by default.Date.prototype.getDate()
Date.prototype.getDay()
Date.prototype.getFullYear()
Date.prototype.getHours()
Date.prototype.getMilliseconds()
Date.prototype.getMinutes()
Date.prototype.getMonth()
Date.prototype.getSeconds()
Date.prototype.getTime()
Date.prototype.getTimezoneOffset()
Date.prototype.getUTCDate()
Date.prototype.getUTCDay()
Date.prototype.getUTCFullYear()
Date.prototype.getUTCHours()
Date.prototype.getUTCMilliseconds()
Date.prototype.getUTCMinutes()
Date.prototype.getUTCMonth()
Date.prototype.getUTCSeconds()
Date.prototype.getYear()
getFullYear()
instead.Date.prototype.setDate()
Date.prototype.setFullYear()
Date.prototype.setHours()
Date.prototype.setMilliseconds()
Date.prototype.setMinutes()
Date.prototype.setMonth()
Date.prototype.setSeconds()
Date.prototype.setTime()
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()
Date.prototype.setUTCFullYear()
Date.prototype.setUTCHours()
Date.prototype.setUTCMilliseconds()
Date.prototype.setUTCMinutes()
Date.prototype.setUTCMonth()
Date.prototype.setUTCSeconds()
Date.prototype.setYear()
setFullYear()
instead.Date.prototype.toDateString()
Date
as a human-readable string.Date.prototype.toISOString()
Date.prototype.toJSON()
Date
using toISOString()
. Intended for use by JSON.stringify()
.Date.prototype.toGMTString()
Date
based on the GMT (UT) time zone. Use toUTCString()
instead.Date.prototype.toLocaleDateString()
Date.prototype.toLocaleFormat()
Date.prototype.toLocaleString()
Object.prototype.toLocaleString()
method.Date.prototype.toLocaleTimeString()
Date.prototype.toSource()
Date
object; you can use this value to create a new object. Overrides the Object.prototype.toSource()
method.Date.prototype.toString()
Date
object. Overrides the Object.prototype.toString()
method.Date.prototype.toTimeString()
Date
as a human-readable string.Date.prototype.toUTCString()
Date.prototype.valueOf()
Date
object. Overrides the Object.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 Latest Draft (ECMA-262) The definition of 'Date.prototype' in that specification. | Living Standard |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes | Yes | Yes | Yes |
Ordinary object (ES2015) | ? | ? | 41 | ? | ? | ? |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Ordinary object (ES2015) | ? | ? | ? | 41 | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype