Date.prototype 属性表示Date构造函数的原型。
Date.prototype 属性的属性特性: |
|
|---|---|
| writable | false |
| enumerable | false |
| configurable | true |
Date实例继承自Date.prototype。可以通过修改构造函数的原型对象来影响 Date实例继承的属性和方法。
为了兼容千禧年计算(也即考虑到 2000 年),应该总是指定完整的年份,例如,使用 1998,而不是 98。为了方便以完整的格式指定年份, JavaScript 包含了相应的方法getFullYear(),setFullYear(), getUTCFullYear() 和setUTCFullYear()。
从 ECMAScript 6 开始,Date.prototype本身就是一个普通的对象。不是Date的实例。
Date.prototype.constructorDate构造函数。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() .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.prototype.setUTCDate()Date.prototype.setUTCFullYear()Date.prototype.setUTCHours()Date.prototype.setUTCMilliseconds()Date.prototype.setUTCMinutes()Date.prototype.setUTCMonth()Date.prototype.setUTCSeconds()Date.prototype.setYear() setFullYear() 方法代替。Date.prototype.toDateString()Date.prototype.toISOString()Date.prototype.toJSON()toISOString() 返回一个表示该日期的字符串。为了在 JSON.stringify() 方法中使用。Date.prototype.toGMTString() toUTCString() 方法代替。Date.prototype.toLocaleDateString()Date.prototype.toLocaleFormat() Date.prototype.toLocaleString()Object.prototype.toLocaleString() 方法。Date.prototype.toLocaleTimeString()Date.prototype.toSource() Date等价的原始字符串对象,你可以使用这个值去生成一个新的对象。重写了 Object.prototype.toSource() 这个方法。Date.prototype.toString()Object.prototype.toString() 方法。Date.prototype.toTimeString()Date.prototype.toUTCString()Date.prototype.valueOf()Object.prototype.valueOf() 方法。| Specification | Status | Comment |
|---|---|---|
| ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.1. |
| ECMAScript 5.1 (ECMA-262) Date.prototype |
Standard | |
| ECMAScript 2015 (6th Edition, ECMA-262) Date.prototype |
Standard | |
| ECMAScript Latest Draft (ECMA-262) Date.prototype |
Draft |
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.
| Desktop | Mobile | Server | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
prototype | Chrome Full support Yes | Edge Full support 12 | Firefox
Full support
1
| IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android
Full support
4
| Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |