From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/date/setutcmonth/index.html | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html new file mode 100644 index 0000000000..0e3ffb7782 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html @@ -0,0 +1,90 @@ +--- +title: Date.prototype.setUTCMonth() +slug: Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth +translation_of: Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth +--- +
{{JSRef}}
+ +

setUTCMonth()方法根据通用的时间来设置一个准确的月份

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

语法

+ +
dateObj.setUTCMonth(monthValue[, dayValue])
+ +

参数

+ +
+
monthValue
+
一个0-11的整数,代表1月到12月。
+
dayValue
+
可选参数:一个1-31的整数,代表一个月的天数。
+
+ +

返回值

+ +

这个数值是从1970年1月1号 00:00:00到当前时间的毫秒数(国际通用时间)

+ +

描述

+ +

如果你没有明确书写dayValue 这个参数,那么就会从{{jsxref("Date.prototype.getUTCDate()", "getUTCDate()")}} 方法返回对应的数值.

+ +

如果你写了一个超过在规定的范围内的参数. setUTCMonth()就会试图相应的更新时间信息在Data对象中。例如,如果你用15作为monthValue的值,那么年份就会加1,并且月份会变成3.(15=12+3)

+ +

示例

+ +

使用 setUTCMonth()

+ +
var theBigDay = new Date();
+theBigDay.setUTCMonth(11);
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
规范状态注释
{{SpecName('ES1')}}{{Spec2('ES1')}}最初定义并使用在javascript 1.3版本中
{{SpecName('ES5.1', '#sec-15.9.5.39', 'Date.prototype.setUTCMonth')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-date.prototype.setutcmonth', 'Date.prototype.setUTCMonth')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-date.prototype.setutcmonth', 'Date.prototype.setUTCMonth')}}{{Spec2('ESDraft')}} 
+ +

浏览器兼容性

+ +
+ + +

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

+
+ +

更多

+ + -- cgit v1.2.3-54-g00ecf