aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/date/setutcmilliseconds/index.html
blob: b3059be4cb87eb370bc1692d1e570c4ce7304f2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
title: Date.prototype.setUTCMilliseconds()
slug: Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds
translation_of: Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds
---
<div>{{JSRef}}</div>

<p><strong><code>setUTCMilliseconds()</code></strong> 方法会根据世界时来设置指定时间的毫秒数。</p>

<div>{{EmbedInteractiveExample("pages/js/date-setutcmilliseconds.html")}}</div>



<h2 id="语法">语法</h2>

<pre class="syntaxbox"><code><var>dateObj</var>.setUTCMilliseconds(<var>millisecondsValue</var>)</code></pre>

<h3 id="参数">参数</h3>

<dl>
 <dt><code>millisecondsValue</code></dt>
 <dd>0 - 999 之间的数值,代表毫秒数。</dd>
</dl>

<h3 id="返回值">返回值</h3>

<p>返回更新后的时间距 1970 年 1 月 1 日 00:00:00 (UTC) 的毫秒数。</p>

<h2 id="描述">描述</h2>

<p>如果传递的参数超出了指定的范围,<code>setUTCMilliseconds() 方法会相应地尝试更新储存在 </code>{{jsxref("Date")}}  的时间信息。例如,假设你传递参数的值是 1100,存储在 {{jsxref("Date")}} 的秒数会加 1,然后使用 100 来作为毫秒数。</p>

<h2 id="示例">示例</h2>

<h3 id="使用_setUTCMilliseconds()_方法">使用 <code>setUTCMilliseconds() 方法</code></h3>

<pre class="brush: js">var theBigDay = new Date();
theBigDay.setUTCMilliseconds(500);
</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.29', 'Date.prototype.setUTCMilliseconds')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-date.prototype.setutcmilliseconds', 'Date.prototype.setUTCMilliseconds')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-date.prototype.setutcmilliseconds', 'Date.prototype.setUTCMilliseconds')}}</td>
   <td>{{Spec2('ESDraft')}}</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.setUTCMilliseconds")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{jsxref("Date.prototype.getUTCMilliseconds()")}}</li>
 <li>{{jsxref("Date.prototype.setMilliseconds()")}}</li>
</ul>