JavaScript setMinutes(): Set or Change Minutes

Date.prototype.setMinutes() changes the minutes of an existing Date in local time. It can optionally set seconds and milliseconds at the same time, normalizes values outside 0–59, mutates the Date, and returns the updated timestamp.

Syntax:

date.setMinutes(minutes);
date.setMinutes(minutes, seconds, milliseconds);

A basic example:

const date = new Date(2026, 8, 10, 14, 5);
date.setMinutes(15);
console.log(date.getMinutes()); // 15

Setting the Minutes Top ↑

The original example set the minute field to a fixed value. That remains the simplest use:

const date = new Date();
date.setMinutes(20);
console.log(date.toTimeString());

Setting Seconds and Milliseconds Top ↑

const date = new Date();
date.setMinutes(30, 45, 250);
console.log(date);

Overflow and Negative Minute Values Top ↑

Values above 59 carry into the next hour. Negative values move into an earlier hour. The original -75 example is a useful demonstration of this normalization.

const date = new Date(2026, 8, 10, 12, 0);
date.setMinutes(-75);
console.log(date.toString()); // rolls back 1 hour 15 minutes
const date = new Date(2026, 8, 10, 23, 30);
date.setMinutes(90);
console.log(date); // carries into the next day

Adding or Subtracting Minutes Top ↑

const date = new Date();
date.setMinutes(date.getMinutes() + 45);
console.log(date);

For exact elapsed-duration arithmetic, adding milliseconds to getTime() is another option.

Return Value and Mutation Top ↑

const date = new Date();
const timestamp = date.setMinutes(10);
console.log(typeof timestamp); // "number"

Using setUTCMinutes() Top ↑

const date = new Date();
date.setUTCMinutes(0, 0, 0);
console.log(date.toISOString());

Common setMinutes() Mistakes Top ↑

  • Confusing “set minute to 15” with “add 15 minutes.”
  • Forgetting that the method mutates the original Date.
  • Passing NaN, which makes the Date invalid.
  • Using local setters for a calculation defined in UTC.

Next: Date toString() Date Reference




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer