aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html86
1 files changed, 86 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html
new file mode 100644
index 0000000000..9871342a43
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html
@@ -0,0 +1,86 @@
+---
+title: Date.prototype.valueOf()
+slug: Web/JavaScript/Reference/Global_Objects/Date/valueOf
+tags:
+ - Date
+ - JavaScript
+ - 原型
+ - 参考
+ - 方法
+ - 日期
+translation_of: Web/JavaScript/Reference/Global_Objects/Date/valueOf
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>valueOf()</strong></code> 方法返回一个 {{jsxref("Date")}} 对象的原始值。</p>
+
+<div>{{EmbedInteractiveExample("pages/js/date-valueof.html")}}</div>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="syntaxbox"><code><var>dateObj</var>.valueOf()</code></pre>
+
+<h3 id="Parameters" name="Parameters">返回值</h3>
+
+<p>从1970年1月1日0时0分0秒(UTC,即协调世界时)到该日期的毫秒数。</p>
+
+<h2 id="Description" name="Description">描述</h2>
+
+<p><code>valueOf</code> 方法返回以数值格式表示的一个 <code>Date</code> 对象的原始值,从1970年1月1日0时0分0秒(UTC,即协调世界时)到该日期对象所代表时间的毫秒数。</p>
+
+<p>该方法的功能和 {{jsxref("Date.prototype.getTime()")}} 方法一样。</p>
+
+<p>该方法通常在 JavaScript 内部被调用,而不是在代码中显式调用。</p>
+
+<h2 id="Examples" name="Examples">例子</h2>
+
+<h3 id="Example:_Using_valueOf" name="Example:_Using_valueOf">使用 <code>valueOf()</code></h3>
+
+<pre class="brush:js">var x = new Date(56, 6, 17);
+var myVar = x.valueOf(); // assigns -424713600000 to myVar
+</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>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.9.5.8', 'Date.prototype.valueOf')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-date.prototype.valueof', 'Date.prototype.valueOf')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-date.prototype.valueof', 'Date.prototype.valueOf')}}</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.valueOf")}}</p>
+
+<h2 id="See_Also" name="See_Also">相关链接</h2>
+
+<ul>
+ <li>{{jsxref("Object.prototype.valueOf()")}}</li>
+ <li>{{jsxref("Date.prototype.getTime()")}}</li>
+</ul>