The JavaScript setUTCMinutes function is useful for setting UTC Minutes, Seconds, and Milliseconds of a specified date according to the Universal Time zone.
The syntax of the setUTCMinutes function is:
Date.setUTCMinutes(Minutes, Seconds, Milliseconds)
Parameters: The JavaScript setUTCMinutes() method accepts three parameters. Among them, the minutes parameter is required. The seconds and milliseconds are the optional arguments.
Return Value: It updates the given dates UTC minutes, seconds, and milliseconds based on the given values. If we pass any number exceeding the range, the dates will roll forward or backward.
JavaScript setUTCMinutes example
In the following example, we use the setUTCMinutes function to set the current date UTC minutes to 45 according to the Universal Coordinated Time zone.
const dt = new Date();
console.log(dt.toUTCString());
dt.setUTCMinutes(45);
console.log(dt.toUTCString());
Tue, 16 Jun 2026 04:14:22 GMT
Tue, 16 Jun 2026 04:45:22 GMT
Example 2: We used the Date() constructor to create a date object from a string date and used the JavaScript setUTCMinutes to set the UTC minutes of a custom date to 30.
const dt = new Date("May 1, 2026 10:11:19 GMT");
console.log(dt.toUTCString());
dt.setUTCMinutes(30);
console.log(dt.toUTCString());
Fri, 01 May 2026 10:11:19 GMT
Fri, 01 May 2026 10:30:19 GMT
Example 3: In this setUTCMinutes method, Seconds and Milliseconds are optional arguments. In the following examples, we use these optional arguments.
In this JavaScript example, we set the current date UTC to 45 minutes and 30 seconds, as per universal time.
const dt = new Date("May 1, 2026 10:11:19 GMT");
console.log(dt.toUTCString());
dt.setUTCMinutes(45, 30);
console.log(dt.toUTCString());
Fri, 01 May 2026 10:11:19 GMT
Fri, 01 May 2026 10:45:30 GMT
Similarly, we use the setUTCMinutes function to set UTC minutes to 50, seconds to 45, and milliseconds to 888.
const dt = new Date("May 1, 2026 10:11:19 GMT");
console.log(dt.toISOString());
dt.setUTCMinutes(50, 45, 888);
console.log(dt.toISOString());
console.log(dt.getUTCMinutes());
console.log(dt.getUTCSeconds());
console.log(dt.getUTCMilliseconds());
2026-05-01T10:11:19.000Z
2026-05-01T10:50:45.888Z
50
45
888
TIP: Please refer to the getUTCMinutes(), getUTCSeconds, and getUTCMilliseconds() methods to extract UTC minutes, seconds, and milliseconds.
Example 4: If we use the minutes value of the JavaScript setUTCMinutes method above 59, the date will roll forward.
In the following example, we used the minutes value of 250, which translates to 4 hours (4 * 60 = 240) and 10 minutes. So, the setUTCMinutes method sets the hours value to 4 hours ahead and sets the minutes value to 10.
const dt = new Date();
console.log(dt.toUTCString());
dt.setUTCMinutes(250);
console.log(dt.toUTCString());
Tue, 16 Jun 2026 04:23:25 GMT
Tue, 16 Jun 2026 08:10:25 GMT
In this JavaScript example, we set the Minutes to 250, the seconds to 45, and the milliseconds to 5000000.
const dt = new Date();
console.log(dt.toUTCString());
dt.setUTCMinutes(250, 45, 5000000);
console.log(dt.toUTCString());
Tue, 16 Jun 2026 04:26:21 GMT
Tue, 16 Jun 2026 09:34:05 GMT
Example 5: If the setUTCMinutes method encounters a negative minutes value, it rolls back to the previous hour’s last minute. Here, -3 means subtract three seconds from the last hour.
const dt = new Date();
console.log(dt.toUTCString());
dt.setUTCMinutes(-3);
console.log(dt.toUTCString());
Tue, 16 Jun 2026 04:28:28 GMT
Tue, 16 Jun 2026 03:57:28 GMT
What is the difference between setMinutes and setUTCMinutes?
The setMinutes method sets the minutes, seconds, and milliseconds value of a given date and time according to the local system time zone. On the other hand, the setUTCMinutes method sets the UTC minutes, UTC seconds, and UTC milliseconds value of a given date and time according to the Universal Coordinated Time zone.
const dt = new Date();
console.log(dt.toUTCString());
dt.setUTCMinutes(50);
console.log(dt.toUTCString());
const d = new Date();
console.log(d);
d.setMinutes(50);
console.log(d);
Tue, 16 Jun 2026 04:37:51 GMT
Tue, 16 Jun 2026 04:50:51 GMT
Tue Jun 16 2026 10:07:51 GMT+0530 (India Standard Time)
Tue Jun 16 2026 10:50:51 GMT+0530 (India Standard Time)