JavaScript Date.setMinutes()

Why setMinutes ?

JavaScript Date The setMinutes () method is a built-in function. This method returns the minutes of a specific date. This method can also be used to set seconds and milliseconds.

Syntax:

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

  • minutesValue: Represents the minutes. It takes values between 0 and 59.
  • secondsValue: Represents the second. It takes values between 0 and 59.
  • msValue: represents militias. Gets values from 0 to 999.

return:

  • It returns the new date with updated minute which is set by setMinutes() function.

JavaScript setMinutes Examples

Example 1

Date With the setMinutes () method, we can change the minute value of a specific date.

        var date = new Date('April 21, 1983 13:22:32:77');
        console.log(date.getMinutes());

        date.setMinutes(55);
        console.log(date.getMinutes())

22
55


Example 2

Date With the setMinutes () method, we can change the current minute value.

        var date = new Date();
        console.log(date.getMinutes());

        date.setMinutes(12);
        console.log(date.getMinutes())

25
12


Example 3

        var date = new Date();
        console.log(date.getMinutes("April 21, 1983 22:47:55"));

        date.setMinutes(55);
        console.log(date.getMinutes())
        console.log(date.getMilliseconds())

27
55
836


Browser Support

Chromeyes
Edgeyes
Firefox1
Internet Exploreryes
Operayes
Safariyes
Android webviewyes
Chrome for Androidyes
Edge mobileyes
Firefox for Android4
Opera Androidyes

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started