JavaScript setTime () method
Examples
In this example, we will be January 1, 1970 to add 1332403882588 milliseconds, and displays the new date and time:
var d = new Date();
d.setTime(1332403882588);
d.setTime(1332403882588);
d output:
try it"
Definition and Usage
setTime () method of Date object in milliseconds.
Browser Support
All major browsers support setTime () method
grammar
Date .setTime (millisec)
Parameter Values
parameter | description |
---|---|
millisec | Required. Date and time to be set according to the number of milliseconds GMT January 1, 1970 between midnight. Millisecond value of this type can be passed to the Date () constructor, this value can be obtained by calling Date.UTC () and Date.parse () method. Date expressed in milliseconds can make it independent of the time zone. |
return value
Types of | description |
---|---|
Number | Return parameter millisec. Prior to ECMAScript standardization, this method does not return a value. |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
In this case, we will subtract 1970/01/01 1332403882588 milliseconds, and displays the new date and time:
var d = new Date ();
d.setTime (-1332403882588);
d.setTime (-1332403882588);
d resulting output:
try it"