Method
JavaScript Date getMinutes() Method
The JavaScript Date getMinutes() method is used to return the minutes from a given Date object. The getMinutes() method returns the minutes (from 0 to 59) of the specified date and time.
Syntax
[dm_code_snippet background=”yes” background-mobile=”yes” slim=”no” line-numbers=”no” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
dateObj.getMinutes()
[/dm_code_snippet]
dateObj is a Date object which represents the date and time.
Example
You can try to run the following code to get the minutes from a given date.
[dm_code_snippet background=”yes” background-mobile=”yes” slim=”no” line-numbers=”no” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
<script>
var d = new Date();
var n = d.getMinutes();
document.write("Current minutes: " + n);
</script>
[/dm_code_snippet]
The output of the above code will be:
[dm_code_snippet background=”yes” background-mobile=”yes” slim=”no” line-numbers=”no” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
Current minutes: 15
[/dm_code_snippet]
Browser Support
The getMinutes() method is supported in all major browsers.
Return Value
The getMinutes() method returns the minutes (from 0 to 59) of the specified date and time.