aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/date/settime
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/settime
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/settime')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html80
1 files changed, 80 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html
new file mode 100644
index 0000000000..85fe608f8e
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html
@@ -0,0 +1,80 @@
+---
+title: Date.prototype.setTime()
+slug: Web/JavaScript/Reference/Global_Objects/Date/setTime
+translation_of: Web/JavaScript/Reference/Global_Objects/Date/setTime
+---
+<div>{{JSRef("Global_Objects", "Date")}}</div>
+
+<p><code><strong>setTime()</strong></code> 方法以一个表示从1970-1-1 00:00:00 UTC计时的毫秒数为来为 <code>Date</code> 对象设置时间。</p>
+
+<div>{{EmbedInteractiveExample("pages/js/date-settime.html")}}</div>
+
+
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="syntaxbox"><var>dateObj</var>.setTime(<em>timeValue</em>)</pre>
+
+<h3 id="Parameters" name="Parameters">参数</h3>
+
+<dl>
+ <dt><code>timeValue</code></dt>
+ <dd>一个整数,表示从1970-1-1 00:00:00 UTC开始计时的毫秒数。</dd>
+ <dt>
+ <h3 id="Parameters" name="Parameters">返回值</h3>
+ </dt>
+ <dd>UTC 1970年1月1日00:00:00与更新日期之间的毫秒数(实际上是自变量的值)。</dd>
+</dl>
+
+<h2 id="Description" name="Description">描述</h2>
+
+<p>使用 <code>setTime</code> 方法用来把一个日期时间赋值给另一个 <code>Date </code>对象。</p>
+
+<h2 id="Examples" name="Examples">例子</h2>
+
+<h3 id="Example_Using_setTime" name="Example:_Using_setTime">例子:使用<code>setTime</code></h3>
+
+<pre>theBigDay = new Date("July 1, 1999");
+sameAsBigDay = new Date();
+sameAsBigDay.setTime(theBigDay.getTime());
+</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>ECMAScript 1st Edition. Implemented in JavaScript 1.0</td>
+ <td>Standard</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.9.5.27', 'Date.prototype.setTime')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-date.prototype.settime', 'Date.prototype.setTime')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<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.setTime")}}</p>
+
+<h2 id="See_Also" name="See_Also">相关链接</h2>
+
+<ul>
+ <li>{{jsxref("Date.prototype.getTime()")}}</li>
+ <li>{{jsxref("Date.prototype.setUTCHours()")}}</li>
+</ul>