VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-date-setminutes-method/

⇱ JavaScript Date setMinutes() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Date setMinutes() Method

Last Updated : 11 Jul, 2025

JavaScript date.setMinutes() method is used to set minutes into a Date object which is created using the Date() constructor.

Syntax:

DateObj.setMinutes(Minutes_Value)

Parameter: This method accepts a single parameter as mentioned above and described below:

  • minutes_Value: This parameter holds the value of minutes which is used to set in the Date() constructor.

Return Value: It returns the new date with the updated minute which is set by the setMinutes() method.

Note: The DateObj is a valid Date object created using the Date() constructor in which we want to set the minute. The value of the minute is from 0 to 59.

The below examples illustrate the JavaScript Date setMinutes() Method:

Example 1: If in the Date() constructor we do not give any minute while creating the Date object, still setMinutes() method set a new minute which is given as its parameter.

Output:

51

Example 2: If nothing as a parameter is given in the Date() constructor, still setMinutes() method set minutes but a month, year, date, etc become current ones. Here 42 is the new minutes, 3 is the current month i.e. April, 1 is the current date and 2018 is the current year.

Output:

42
3
1
2018

Example 3: If the value of the minute is 66 as given in the parameter of the setMinutes() function, It will set 6 as the minute because the minute range is from 0 to 59 and (66%60 = 6). Here 6 is the new minute and the hour becomes 06 from 05 because the minute range is from 0 to 59 i.e., a total of 60 and we set the new minute as 66 which increases the hour by one to 06 from 05 and the minute becomes 6.

Output:

6
6

Supported Browsers:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Internet Explorer 3 and above
  • Opera 3 and above
  • Safari 1 and above

We have a complete list of Javascript Javascript Date methods, to check those please go through the article.

Comment