aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/setutcmonth/index.html90
1 files changed, 90 insertions, 0 deletions
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
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>setUTCMonth()方法根据通用的时间来设置一个准确的月份</code></strong></p>
+
+<div>{{EmbedInteractiveExample("pages/js/date-setutcmonth.html")}}</div>
+
+
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><code><var>dateObj</var>.setUTCMonth(<var>monthValue</var>[, <var>dayValue</var>])</code></pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>monthValue</code></dt>
+ <dd>一个0-11的整数,代表1月到12月。</dd>
+ <dt><code>dayValue</code></dt>
+ <dd>可选参数:一个1-31的整数,代表一个月的天数。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>这个数值是从1970年1月1号 00:00:00到当前时间的毫秒数(国际通用时间)</p>
+
+<h2 id="描述">描述</h2>
+
+<p>如果你没有明确书写<code>dayValue</code> 这个参数,那么就会从{{jsxref("Date.prototype.getUTCDate()", "getUTCDate()")}} 方法返回对应的数值.</p>
+
+<p>如果你写了一个超过在规定的范围内的参数. <code>setUTCMonth()就会试图相应的更新时间信息在Data对象中。例如,如果你用15作为</code>monthValue的值,那么年份就会加1,并且月份会变成3.(15=12+3)</p>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="使用_setUTCMonth()">使用 <code>setUTCMonth()</code></h3>
+
+<pre class="brush: js">var theBigDay = new Date();
+theBigDay.setUTCMonth(11);
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">注释</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>最初定义并使用在javascript 1.3版本中</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.9.5.39', 'Date.prototype.setUTCMonth')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-date.prototype.setutcmonth', 'Date.prototype.setUTCMonth')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-date.prototype.setutcmonth', 'Date.prototype.setUTCMonth')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("javascript.builtins.Date.setUTCMonth")}}</p>
+</div>
+
+<h2 id="更多">更多</h2>
+
+<ul>
+ <li>{{jsxref("Date.prototype.getUTCMonth()")}}</li>
+ <li>{{jsxref("Date.prototype.setMonth()")}}</li>
+</ul>