Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript setMinutes() Method

JavaScript setMinutes() Method

Date Object Reference JavaScript Date object

Example

Set the minutes field to 17:

var d = new Date();

d.setMinutes(17);

d Output result:

Try it »


Definition and Usage

The setMinutes() method is used to set the minutes field of a specified time.

This method can also be used to set the seconds and milliseconds.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the setMinutes() method.


Syntax

Date

.setMinutes(

min

,

sec

,

millisec

)

Parameter value

Parameters Description
min Required. A value representing the minutes,

between 0 and 59, in local time (the same applies below):

  • -1 is the last minute of the previous hour
  • 60 is the first minute of the next hour
  • | | *sec* | Optional. A value representing the seconds,

    between 0 and 59. This parameter was not supported before EMCAScript standardization:

    | | *millisec* | Optional. A value representing the milliseconds

    , between 0 and 999. This parameter was not supported before EMCAScript standardization:

    |

    Return Value

    Type Description
    Number Returns the number of milliseconds from January 1, 1970 to the adjusted date. Before ECMAScript standardization, this method returned nothing.

    Technical Details

    JavaScript version: 1.0

    More examples

    Example

    Set the date to 90 minutes earlier:

    var d = new Date();

    d.setMinutes(d.getMinutes()-90);

    d Output result:

    Try it »


    Date Object Reference JavaScript Date object