JavaScript Date setMilliseconds()

Example

const d = new Date();
d.setMilliseconds(192);
Try it Yourself »

Description

setMilliseconds() sets the milliseconds of a date.

Browser Support

setMilliseconds() is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Syntax

Date.setMilliseconds(millisec)

Parameters

millisec Required. The milliseconds.

(0 to 999), but other values are allowed:

  • -1 gives the last millisecond of the previous second
  • 1000 gives first millisecond of the next second
  • 1001 gives the second millisecond of the next second

Return Value

A number.

Number of milliseconds between the date and January 1, 1970 00:00:00 UTC.
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.