offline version v3


138 of 264 menu

setSeconds method

The setSeconds method allows you to change the number of seconds for the date object. It takes the number of seconds as the first parameter. It can also take milliseconds.

Syntax

date.setSeconds(seconds, [milliseconds]);

Example

Let's set the seconds for the current point in time:

let date = new Date(); date.setSeconds(59); console.log(date);

Example

Let's set the seconds and milliseconds for the current point in time:

let date = new Date(); date.setSeconds(59, 999); console.log(date);

See also

enru