Apply your JS skills to key Mozilla projects as an MDN Fellow! http://mzl.la/MDNFellowship

mozilla

Revision 8644 of Date.prototype.getTime()

  • Revision slug: JavaScript/Reference/Global_Objects/Date/getTime
  • Revision title: getTime
  • Revision id: 8644
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment 23 words added, 26 words removed

Revision Content

 

Summary

Returns the numeric value corresponding to the time for the specified date according to universal time.

Method of Date
Implemented in JavaScript 1.0
ECMAScript Edition ECMAScript 1st Edition

Syntax

getTime()

Parameters

None.

Description

The value returned by the getTime method is the number of milliseconds since 1 January 1970 00:00:00 UTC. You can use this method to help assign a date and time to another Date object.

This method is functionally equivalent to the valueOf method.

Examples

Examples

Constructing a date object with the identical time value.

var birthday = new Date(1994, 12, 10);
var copy = new Date();
copy.setTime(birthday.getTime());

See also

getUTCHours, setTime, valueOf

{{ languages( { "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Date/getTime", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Date/getTime" } ) }}

Revision Source

<p> </p>
<h3 name="Summary">Summary</h3>
<p>Returns the numeric value corresponding to the time for the specified date according to universal time.</p>
<table class="standard-table"> <thead> <tr> <th class="header" colspan="2">Method of <a href="/en/JavaScript/Reference/Global_Objects/Date"><code>Date</code></a></th> </tr> </thead> <tbody> <tr> <td>Implemented in</td> <td>JavaScript 1.0</td> </tr> <tr> <td>ECMAScript Edition</td> <td>ECMAScript 1st Edition</td> </tr> </tbody>
</table> <h3 name="Syntax">Syntax</h3>
<p><code> getTime() </code></p>
<h3 name="Parameters">Parameters</h3>
<p>None.</p>
<h3 name="Description">Description</h3>
<p>The value returned by the <code>getTime</code> method is the number of milliseconds since 1 January 1970 00:00:00 UTC. You can use this method to help assign a date and time to another <code>Date</code> object.</p>
<p>This method is functionally equivalent to the <a href="/en/JavaScript/Reference/Global_Objects/Date/valueOf" title="en/JavaScript/Reference/Global_Objects/Date/valueOf">valueOf</a> method.</p>
<h3 name="Examples">Examples</h3>
<h4 name="Examples">Examples</h4>
<p>Constructing a date object with the identical time value.</p>
<pre class="brush: js">var birthday = new Date(1994, 12, 10);
var copy = new Date();
copy.setTime(birthday.getTime());
</pre><h3 name="See_also">See also</h3>
<p><a href="/en/JavaScript/Reference/Global_Objects/Date/getUTCHours" title="en/JavaScript/Reference/Global_Objects/Date/getUTCHours">getUTCHours</a>, <a href="/en/JavaScript/Reference/Global_Objects/Date/setTime" title="en/JavaScript/Reference/Global_Objects/Date/setTime">setTime</a>, <a href="/en/JavaScript/Reference/Global_Objects/Date/valueOf" title="en/JavaScript/Reference/Global_Objects/Date/valueOf">valueOf</a></p> <p>{{ languages( { "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Date/getTime", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Date/getTime" } ) }}</p>
Revert to this revision