Javascript Reference - JavaScript getMinutes() Method








getMinutes()
Returns the date's minutes as a number between 0 and 59.

Browser Support

getMinutes() Yes Yes Yes Yes Yes

Syntax

dateObject.getMinutes();

Parameters

None

Return Value

return a number from 0 to 59 representing minutes.





Example


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

The code above generates the following result.

Example 2

The following code return the minutes from a specific date and time:


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- ww  w  .  j a  v a  2  s.co  m-->
    var d = new Date("July 12, 1987 01:15:00");
    var n = d.getMinutes();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

The code above is rendered as follows: