Now you can listen to this article with the Online Text Reader


JavaScript getTime Method





The getTime method returns the quantity of milliseconds passed since January 1st 1970 until the point in time stored in a Date object. The value returned by this method is an integer number.


Syntax

myDate.getTime()

With myDate being an object based on the Date object.


Example

The following code uses the getTime method to return the quantity of milliseconds passed since January 1st 1970 until the current date:

<script type="text/javascript">

var currentDate = new Date();

document.write("It has been " + currentDate.getTime() + " milliseconds since January 1st 1970.");

</script>


Technical Details

The getTime method belongs to the Date object, it is available since the version 1.0 of JavaScript, and it is supported in all major browsers.





JavaScript Manual >> Date Object >> getTime Method





© Copyright 2010-2018 ROM Cartridge



Books to Read and Listen to Online