.setUTCMinutes()
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. Ifseconds
is specified,minutes
must also be specified.ms
: An integer value between 0 and 999 representing the milliseconds. Ifms
is specified,minutes
andseconds
must also be specified.
If seconds
and 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
Looking to contribute?
- 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.