JavaScript Date setUTCMinutes() method

The setUTCMinutes method in JavaScript is designed to assign the minute value for a given date according to Coordinated Universal Time (UTC).

Syntax

The syntax for the setUTCMinutes method can be expressed as follows:

Example

dateObj.setUTCMinutes( minValue[, secValue[, msValue]]])

Parameter

minValue - This denotes an integer within the range of 0 to 59, indicating the minutes. Should the supplied minute value exceed 59, the setUTCMinutes function will adjust the hour value upwards as necessary.

secValue - This parameter is not mandatory. It denotes an integer ranging from 0 to 59, indicating the seconds. Should the supplied second value exceed 59, the setUTCMinutes function will adjust the minute value as necessary.

msValue - This parameter is optional. It denotes an integer ranging from 0 to 999, which indicates the milliseconds. In cases where the provided millisecond value exceeds 999, the setUTCMinutes function will adjust the seconds value accordingly.

JavaScript Date setUTCMinutes method example

In this section, we will explore the setUTCMinutes method by examining a range of examples.

Example 1

Let's examine an example that demonstrates how to display both the current minute and the updated minute value.

Example

<script>

var minutes=new Date();	

document.writeln("Current Minute : "+minutes.getUTCMinutes()+"<br>");

minutes.setUTCMinutes(32);

document.writeln("Updated Minute : "+minutes.getUTCMinutes());

</script>

Output:

Output

Current Minute : 23

Updated Minute : 32

Example 2

Consider an example where we aim to modify the minute component of a specified time.

Example

<script>

var minutes=new Date("August 15, 1947 20:22:10 GMT+5:30");	

minutes.setUTCMinutes(25);

document.writeln("Updated Minute : "+minutes.getUTCMinutes());

</script>

Output:

Output

Updated Minute : 25

Example 3

In this illustration, we will define the seconds value (exceeding 59) in conjunction with the minutes.

Example

<script>

var minutes=new Date("August 15, 1947 20:22:10 GMT+5:30");	

minutes.setUTCMinutes(25,62);

document.writeln("Updated Minute : "+minutes.getUTCMinutes());

</script>

Output:

Output

Updated Minute : 26

Input Required

This code uses input(). Please provide values below: