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/getutcmonth/index.html | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth') diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html new file mode 100644 index 0000000000..015b513a72 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html @@ -0,0 +1,76 @@ +--- +title: Date.prototype.getUTCMonth() +slug: Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth +translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth +--- +
{{JSRef("Global_Objects", "Date")}}
+ +

getUTCMonth() 方法以世界时为标准,返回一个指定的日期对象的月份,它是从 0 开始计数的(0 代表一年的第一个月)。

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

语法

+ +
dateObj.getUTCMonth()
+ +

参数

+ +

无。

+ +

返回值

+ +

getUTCMonth() 返回一个 0 到 11 的整数,分别对应以下月份:0 代表一月,1 代表二月,2 代表三月,依次类推。

+ +

例子

+ +

例子: 使用 getUTCMonth() 方法

+ +

下例将当前时间的月份赋值给变量 month

+ +
var today = new Date();
+var month = today.getUTCMonth();
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + +
规范版本规范状态注解
ECMAScript 1st Edition.StandardInitial definition. Implemented in JavaScript 1.3.
{{SpecName('ES5.1', '#sec-15.9.5.13', 'Date.prototype.getUTCMonth')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-date.prototype.getutcmonth', 'Date.prototype.getUTCMonth')}}{{Spec2('ES6')}} 
+ +

浏览器兼容性

+ +
+ + +

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

+
+ +

相关链接

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