.setUTCSeconds()
Anonymous contributor
Published Jul 29, 2023
Contribute to Docs
The .setUTCSeconds()
method sets the second value of a Date
object according to Coordinated Universal Time(UTC) and returns the updated Date
object.
Syntax
myDate.setUTCSeconds(secondsValue)
myDate.setUTCSeconds(secondsValue, millisecondsValue)
The .setUTCSeconds()
method is called on the myDate
object with an input argument secondsValue
that passes the new value for seconds.
Optionally, the method can also set the date’s millisecond UTC values. The valid number ranges for the time units are as follows:
Seconds
(Required): 0 to 59Milliseconds
(optional): 0 to 999
Example
This example sets the second value of the eventSeconds
object to 35
.
const eventSeconds = new Date('2023-06-25T00:00:00');eventSeconds.setUTCSeconds(35);console.log(eventSeconds);
This example will output the following:
2023-06-25T00:00:35.000Z
Codebyte Example
This code example sets the second and millisecond values of eventSeconds
to 35
and 465
respectively. The values are then logged to the console.
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly15 hours