diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/date/setutcdate | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-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/setutcdate')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html new file mode 100644 index 0000000000..8f0a425e96 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html @@ -0,0 +1,77 @@ +--- +title: Date.prototype.setUTCDate() +slug: Web/JavaScript/Reference/Global_Objects/Date/setUTCDate +translation_of: Web/JavaScript/Reference/Global_Objects/Date/setUTCDate +--- +<div>{{JSRef("Global_Objects", "Date")}}</div> + +<p><strong><code>setUTCDate()</code></strong> 方法就是根据全球时间设置特定date对象的日期。</p> + +<div>{{EmbedInteractiveExample("pages/js/date-setutcdate.html")}}</div> + + + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre class="syntaxbox"><code><var>dateObj</var>.setUTCDate(<var>dayValue</var>)</code></pre> + +<h3 id="Parameters" name="Parameters">参数</h3> + +<dl> + <dt><code>dayValue</code></dt> + <dd>一个1-31的整形数字,用来指定日期。</dd> +</dl> + +<h2 id="Description" name="Description">描述</h2> + +<p>如果你指定的参数超出了范围,setUTCDate()会尝试更新对应的{{jsxref("Global_Objects/Date", "Date")}} 中的日期信息。例如,如果你使用了40来作为参数,但是{{jsxref("Global_Objects/Date", "Date")}} 中存储的月份为6月,那么日期将被改写为10且月份被增到7月。</p> + +<h2 id="Examples" name="Examples">示例</h2> + +<h3 id="Example:_Using_setUTCDate" name="Example:_Using_setUTCDate">使用Using <code>setUTCDate()</code></h3> + +<pre class="brush: js">var theBigDay = new Date(); +theBigDay.setUTCDate(20); +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>ECMAScript 1st Edition.</td> + <td>Standard</td> + <td>Initial definition. Implemented in JavaScript 1.3.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.9.5.37', 'Date.prototype.setUTCDate')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-date.prototype.setutcdate', 'Date.prototype.setUTCDate')}}</td> + <td>{{Spec2('ES6')}}</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.setUTCDate")}}</p> +</div> + +<h2 id="See_also" name="See_also">相关内容</h2> + +<ul> + <li>{{jsxref("Date.prototype.getUTCDate()")}}</li> + <li>{{jsxref("Date.prototype.setDate()")}}</li> +</ul> |