From http://www.w3schools.com (Copyright Refsnes Data)
JavaScript Date Object
The setTime() method is used to calculate a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970.
| dateObject.setTime(millisec) |
| Parameter | Description |
|---|---|
| millisec | Required. A numeric value representing the milliseconds since midnight January 1, 1970. Can be a negative number |
Note: This method is always used in conjunction with a Date object.
Example 1Add 77771564221 milliseconds to 1970/01/01 and display the new date and time:
The output of the code above will be:
Try it yourself » |
Example 2Subtract 77771564221 milliseconds from 1970/01/01 and display the new date and time:
The output of the code above will be:
Try it yourself » |
JavaScript Date Object
From http://www.w3schools.com (Copyright Refsnes Data)