Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript setMilliseconds() Method

JavaScript setMilliseconds() Method

Date Object Reference JavaScript Date object

Example

Set the milliseconds field of the specified time to 192:

var d = new Date();

d.setMilliseconds(192);

var n = d.getMilliseconds();

n Output result:

Try it »


Definition and Usage

The setMilliseconds() method is used to set the milliseconds field of a specified time.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the setMilliseconds() method.


Syntax

Date

.setMilliseconds(

millisec

)

Parameter value

Parameters Description
millisec Required. Used to set the milliseconds field of dateObject.

This parameter is an integer between 0 and 999:

  • -1 is the last millisecond of the previous second
  • 1000 is the first millisecond of the next second
  • 1001 is the second millisecond of the next second.
  • |

    Return Value

    Type Description
    Number Milliseconds from midnight on January 1, 1970 to the adjusted date.

    Technical Details

    JavaScript version: 1.3

    Date Object Reference JavaScript Date object