Skip to content
Advertisements

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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: