Javascript Date setMinutes(minutes)

Introduction

Javascript Date setMinutes(minutes) sets the date's minutes.

Setting the minutes to a number greater than 59 also increments the hour.

dateObj.setMinutes(minutesValue[, secondsValue[, msValue]])

Parameters

  • minutesValue - An integer between 0 and 59, representing the minutes.
  • secondsValue - Optional. An integer between 0 and 59, representing the seconds. If you specify the secondsValue parameter, you must also specify the minutesValue.
  • msValue - Optional. A number between 0 and 999, representing the milliseconds. If you specify the msValue parameter, you must also specify the minutesValue and secondsValue.

Return value

The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.

If value is outside of the range, setMinutes() will update the date accordingly.

var d = new Date();
console.log(d);/*  w ww.  j a  v  a2s  .  co  m*/
d.setMinutes(45);
console.log(d);

Set the date time to be 90 minutes ago:

var d = new Date();
d.setMinutes(d.getMinutes() - 90);// w w  w.  j a va  2  s . com
console.log(d);



PreviousNext

Related