JavaScript .setUTCMinutes()
Published Jun 28, 2023
Contribute to Docs
The .setUTCMinutes() method changes the minutes of a Date instance according to universal time (UTC).
Syntax
setUTCMinutes(minutes)
setUTCMinutes(minutes, seconds)
setUTCMinutes(minutes, seconds, ms)
minutes: An integer value between 0 and 59 representing the minutes.seconds: An integer value between 0 and 59 representing the seconds. Ifsecondsis specified,minutesmust also be specified.ms: An integer value between 0 and 999 representing the milliseconds. Ifmsis specified,minutesandsecondsmust also be specified.
If secondsand ms are not specified, the values returned from getUTCSeconds() and getUTCMilliseconds() methods are used.
The method changes the Date instance and returns the modified timestamp. If a parameter is NaN, the date is invalid and NaN is returned.
Example
In the following example, the .toUTCString() method converts a Date object to a string representation using the UTC timezone.
const date = new Date(Date.UTC(2023, 5, 23, 12, 34, 56)); // Year, Month , Day, Hour, Minute, Secondconsole.log('Before:', date.toUTCString()); // Before: Wed, 23 Jun 2023 12:34:56 GMTdate.setUTCMinutes(45);console.log('After:', date.toUTCString()); // After: Wed, 23 Jun 2023 12:45:56 GMT
This example results in the following output.
Before: Wed, 23 Jun 2023 12:34:56 GMTAfter: Wed, 23 Jun 2023 12:45:56 GMT
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
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
- Beginner Friendly.15 hours