From 310fd066e91f454b990372ffa30e803cc8120975 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 12:56:40 +0100 Subject: unslug zh-cn: move --- .../global_objects/date/prototype/index.html | 181 --------------------- 1 file changed, 181 deletions(-) delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/date/prototype/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/date') diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/prototype/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/prototype/index.html deleted file mode 100644 index da3d715018..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/date/prototype/index.html +++ /dev/null @@ -1,181 +0,0 @@ ---- -title: Date.prototype -slug: Web/JavaScript/Reference/Global_Objects/Date/prototype -tags: - - Date - - JavaScript - - Property -translation_of: Web/JavaScript/Reference/Global_Objects/Date -translation_of_original: Web/JavaScript/Reference/Global_Objects/Date/prototype ---- -
{{JSRef}}
- -

Date.prototype 属性表示{{jsxref("Date")}}构造函数的原型。

- -
{{js_property_attributes(0,0,1)}}
- -

描述

- -

{{jsxref("Date")}}实例继承自Date.prototype。可以通过修改构造函数的原型对象来影响 {{jsxref("Date")}}实例继承的属性和方法。

- -

为了兼容千禧年计算(也即考虑到 2000 年),应该总是指定完整的年份,例如,使用 1998,而不是 98。为了方便以完整的格式指定年份, JavaScript 包含了相应的方法{{jsxref("Global_Objects/Date/getFullYear", "getFullYear()")}},{{jsxref("Global_Objects/Date/setFullYear", "setFullYear()")}}, {{jsxref("Global_Objects/Date/getUTCFullYear", "getUTCFullYear()")}} 和{{jsxref("Global_Objects/Date/setUTCFullYear", "setUTCFullYear()")}}。

- -

从 ECMAScript 6 开始,Date.prototype本身就是一个普通的对象。不是{{jsxref("Date")}}的实例。

- -

属性

- -
-
Date.prototype.constructor
-
返回创建该实例的函数。默认是Date构造函数。
-
- -

方法

- -

Getter

- -
-
{{jsxref("Date.prototype.getDate()")}}
-
根据本地时间返回指定日期对象的月份中的第几天(1-31)。
-
{{jsxref("Date.prototype.getDay()")}}
-
根据本地时间返回指定日期对象的星期中的第几天(0-6)。
-
{{jsxref("Date.prototype.getFullYear()")}}
-
根据本地时间返回指定日期对象的年份(四位数年份时返回四位数字)。
-
{{jsxref("Date.prototype.getHours()")}}
-
根据本地时间返回指定日期对象的小时(0-23)。
-
{{jsxref("Date.prototype.getMilliseconds()")}}
-
根据本地时间返回指定日期对象的毫秒(0-999)。
-
{{jsxref("Date.prototype.getMinutes()")}}
-
根据本地时间返回指定日期对象的分钟(0-59)。
-
{{jsxref("Date.prototype.getMonth()")}}
-
根据本地时间返回指定日期对象的月份(0-11)。
-
{{jsxref("Date.prototype.getSeconds()")}}
-
根据本地时间返回指定日期对象的秒数(0-59)。
-
{{jsxref("Date.prototype.getTime()")}}
-
返回从1970-1-1 00:00:00 UTC(协调世界时)到该日期经过的毫秒数,对于1970-1-1 00:00:00 UTC之前的时间返回负值。
-
{{jsxref("Date.prototype.getTimezoneOffset()")}}
-
返回当前时区的时区偏移。
-
{{jsxref("Date.prototype.getUTCDate()")}}
-
根据世界时返回特定日期对象一个月的第几天(1-31).
-
{{jsxref("Date.prototype.getUTCDay()")}}
-
根据世界时返回特定日期对象一个星期的第几天(0-6).
-
{{jsxref("Date.prototype.getUTCFullYear()")}}
-
根据世界时返回特定日期对象所在的年份(4位数).
-
{{jsxref("Date.prototype.getUTCHours()")}}
-
根据世界时返回特定日期对象当前的小时(0-23).
-
{{jsxref("Date.prototype.getUTCMilliseconds()")}}
-
根据世界时返回特定日期对象的毫秒数(0-999).
-
{{jsxref("Date.prototype.getUTCMinutes()")}}
-
根据世界时返回特定日期对象的分钟数(0-59).
-
{{jsxref("Date.prototype.getUTCMonth()")}}
-
根据世界时返回特定日期对象的月份(0-11).
-
{{jsxref("Date.prototype.getUTCSeconds()")}}
-
根据世界时返回特定日期对象的秒数(0-59).
-
{{jsxref("Date.prototype.getYear()")}}{{deprecated_inline}}
-
根据特定日期返回年份 (通常 2-3 位数). 使用 {{jsxref("Global_Objects/Date/getFullYear", "getFullYear()")}} .
-
- -

Setter

- -
-
{{jsxref("Date.prototype.setDate()")}}
-
根据本地时间为指定的日期对象设置月份中的第几天。
-
{{jsxref("Date.prototype.setFullYear()")}}
-
根据本地时间为指定日期对象设置完整年份(四位数年份是四个数字)。
-
{{jsxref("Date.prototype.setHours()")}}
-
根据本地时间为指定日期对象设置小时数。
-
{{jsxref("Date.prototype.setMilliseconds()")}}
-
根据本地时间为指定日期对象设置毫秒数。
-
{{jsxref("Date.prototype.setMinutes()")}}
-
根据本地时间为指定日期对象设置分钟数。
-
{{jsxref("Date.prototype.setMonth()")}}
-
根据本地时间为指定日期对象设置月份。
-
{{jsxref("Date.prototype.setSeconds()")}}
-
根据本地时间为指定日期对象设置秒数。
-
{{jsxref("Date.prototype.setTime()")}}
-
通过指定从 1970-1-1 00:00:00 UTC 开始经过的毫秒数来设置日期对象的时间,对于早于 1970-1-1 00:00:00 UTC的时间可使用负值。
-
{{jsxref("Date.prototype.setUTCDate()")}}
-
根据世界时设置 Date 对象中月份的一天 (1 ~ 31)。
-
{{jsxref("Date.prototype.setUTCFullYear()")}}
-
根据世界时设置 Date 对象中的年份(四位数字)。
-
{{jsxref("Date.prototype.setUTCHours()")}}
-
根据世界时设置 Date 对象中的小时 (0 ~ 23)。
-
{{jsxref("Date.prototype.setUTCMilliseconds()")}}
-
根据世界时设置 Date 对象中的毫秒 (0 ~ 999)。
-
{{jsxref("Date.prototype.setUTCMinutes()")}}
-
根据世界时设置 Date 对象中的分钟 (0 ~ 59)。
-
{{jsxref("Date.prototype.setUTCMonth()")}}
-
根据世界时设置 Date 对象中的月份 (0 ~ 11)。
-
{{jsxref("Date.prototype.setUTCSeconds()")}}
-
根据世界时设置 Date 对象中的秒钟 (0 ~ 59)。
-
{{jsxref("Date.prototype.setYear()")}} {{deprecated_inline}}
-
setYear() 方法用于设置年份。请使用 {{jsxref("Global_Objects/Date/setFullYear", "setFullYear()")}} 方法代替。
-
- -

Conversion getter

- -
-
{{jsxref("Date.prototype.toDateString()")}}
-
以人类易读(human-readable)的形式返回该日期对象日期部分的字符串。
-
{{jsxref("Date.prototype.toISOString()")}}
-
把一个日期转换为符合 ISO 8601 扩展格式的字符串。
-
{{jsxref("Date.prototype.toJSON()")}}
-
使用 {{jsxref("Global_Objects/Date/toISOString", "toISOString()")}} 返回一个表示该日期的字符串。为了在 {{jsxref("JSON.stringify()")}} 方法中使用。
-
{{jsxref("Date.prototype.toGMTString()")}} {{deprecated_inline}}
-
返回一个基于 GMT (UT) 时区的字符串来表示该日期。请使用 {{jsxref("Global_Objects/Date/toUTCString", "toUTCString()")}} 方法代替。
-
{{jsxref("Date.prototype.toLocaleDateString()")}}
-
返回一个表示该日期对象日期部分的字符串,该字符串格式与系统设置的地区关联(locality sensitive)。
-
{{jsxref("Date.prototype.toLocaleFormat()")}} {{non-standard_inline}}
-
使用格式字符串将日期转换为字符串。
-
{{jsxref("Date.prototype.toLocaleString()")}}
-
返回一个表示该日期对象的字符串,该字符串与系统设置的地区关联(locality sensitive)。覆盖了 {{jsxref("Global_Objects/Object/toLocaleString", "Object.prototype.toLocaleString()")}} 方法。
-
{{jsxref("Date.prototype.toLocaleTimeString()")}}
-
返回一个表示该日期对象时间部分的字符串,该字符串格式与系统设置的地区关联(locality sensitive)。
-
{{jsxref("Date.prototype.toSource()")}}{{non-standard_inline}}
-
返回一个与{{jsxref("Date")}}等价的原始字符串对象,你可以使用这个值去生成一个新的对象。重写了 {{jsxref("Object.prototype.toSource()")}} 这个方法。
-
{{jsxref("Date.prototype.toString()")}}
-
返回一个表示该日期对象的字符串。覆盖了{{jsxref("Object.prototype.toString()")}} 方法。
-
{{jsxref("Date.prototype.toTimeString()")}}
-
以人类易读格式返回日期对象时间部分的字符串。
-
{{jsxref("Date.prototype.toUTCString()")}}
-
把一个日期对象转换为一个以UTC时区计时的字符串。
-
{{jsxref("Date.prototype.valueOf()")}}
-
返回一个日期对象的原始值。覆盖了 {{jsxref("Object.prototype.valueOf()")}} 方法。
-
- -

规范

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.1.
{{SpecName('ES5.1', '#sec-15.9.5', 'Date.prototype')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-properties-of-the-date-prototype-object', 'Date.prototype')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-properties-of-the-date-prototype-object', 'Date.prototype')}}{{Spec2('ESDraft')}} 
- -

浏览器兼容性

- - - -

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

-- cgit v1.2.3-54-g00ecf