| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/setUTCSeconds | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since July 2015.
The setUTCSeconds() method of Date instances changes the seconds and/or milliseconds for this date according to universal time.
const date = new Date("December 31, 1975, 23:15:30 GMT+11:00");
console.log(date.getUTCSeconds());
// Expected output: 30
date.setUTCSeconds(39);
console.log(date.getUTCSeconds());
// Expected output: 39
setUTCSeconds(secondsValue)
setUTCSeconds(secondsValue, msValue)
secondsValueAn integer between 0 and 59 representing the seconds.
msValue OptionalAn integer between 0 and 999 representing the milliseconds.
Changes the Date object in place, and returns its new timestamp. If a parameter is NaN (or other values that get coerced to NaN, such as undefined), the date is set to Invalid Date and NaN is returned.
If you do not specify the msValue parameter, the value returned from the
getUTCMilliseconds() method is
used.
If a parameter you specify is outside of the expected range,
setUTCSeconds() attempts to update the date information in the
Date object accordingly. For example, if you use 100 for
secondsValue, the minutes stored in the Date object will be
incremented by 1, and 40 will be used for seconds.
const theBigDay = new Date();
theBigDay.setUTCSeconds(20);
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-date.prototype.setutcseconds |
This page was last modified on Jul 20, 2025 by MDN contributors.
DategetDate()getDay()getFullYear()getHours()getMilliseconds()getMinutes()getMonth()getSeconds()getTime()getTimezoneOffset()getUTCDate()getUTCDay()getUTCFullYear()getUTCHours()getUTCMilliseconds()getUTCMinutes()getUTCMonth()getUTCSeconds()getYear()setDate()setFullYear()setHours()setMilliseconds()setMinutes()setMonth()setSeconds()setTime()setUTCDate()setUTCFullYear()setUTCHours()setUTCMilliseconds()setUTCMinutes()setUTCMonth()setUTCSeconds()setYear()toDateString()toISOString()toJSON()toLocaleDateString()toLocaleString()toLocaleTimeString()toString()toTemporalInstant()toTimeString()toUTCString()valueOf()[Symbol.toPrimitive]()Object/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |