The getMinutes method in JavaScript retrieves the minutes component from a given date, based on the local time settings.
Syntax
The syntax for the getMinutes method is expressed as follows:
Example
dateObj.getMinutes()
Return
A whole number ranging from 0 to 59 that denotes the minute.
JavaScript Date getMinutes method example
In this section, we will explore the getMinutes method by examining a range of examples.
Example 1
Let’s examine an example that demonstrates how to display the current minute’s value.
Example
<script>
var min=new Date();
document.writeln(min.getMinutes());
</script>
Output:
Let's examine an example that demonstrates how to extract and display the minute component from a specified date.
Example
<script>
var min=new Date("August 15, 1947 20:22:10");
document.writeln(min.getMinutes());
</script>
Output: