mozilla

Revision 8643 of Date.prototype.getTime()

  • Revision slug: JavaScript/Reference/Global_Objects/Date/getTime
  • Revision title: getTime
  • Revision id: 8643
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment 6 words added, 10 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

Example: Using getTime

The following example assigns the date value of theBigDay to sameAsBigDay:

theBigDay = new Date("July 1, 1999")
sameAsBigDay = new Date()
sameAsBigDay.setTime(theBigDay.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="Example:_Using_getTime">Example: Using <code>getTime</code></h4>
<p>The following example assigns the date value of <code>theBigDay</code> to <code>sameAsBigDay</code>:</p>
<pre>theBigDay = new Date("July 1, 1999")
sameAsBigDay = new Date()
sameAsBigDay.setTime(theBigDay.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