Home >Web Front-end >JS Tutorial >JavaScript method getMinutes() that returns the minutes field of the time
Definition and Usage
The getMinutes() method returns the minutes field of the time.
Syntax
dateObject.getMinutes()
Return value
The minute field of dateObject, displayed in local time. The return value is an integer between 0 ~ 59.
Tips and Notes:
Note: The value returned by getMinutes() is a two-digit number. However, the return value is not always two digits, if the value is less than 10, only one digit is returned.
Note: This method is always used in conjunction with a Date object.
Example
Example 1
In this example, we can get the minutes of the current time:
<script type="text/javascript"> var d = new Date() document.write(d.getMinutes()) </script>
Output:
0
Example 2
In this example, we will extract the minutes field from a specific date and time:
<script type="text/javascript"> var born = new Date("July 21, 1983 01:15:00") document.write(born.getMinutes()) </script>
Output:
15
The following example demonstrates how to use getMinutes method.
var date = new Date("1/1/2001"); document.write(date.getMinutes()); document.write("<br/>"); date.setMinutes(5); document.write(date.getMinutes());// Output:// 0// 5
Requirements
Supported in the following document modes: Quirks, Internet Explorer 6 Standards Mode, Internet Explorer 7 Standards Mode, Internet Explorer 8 Standards Mode, Internet Explorer 9 Standards Mode, Internet Explorer 10 Standards mode and Internet Explorer 11 Standards mode. Also supported in Store apps (Windows 8 and Windows Phone 8.1).
The above is the detailed content of JavaScript method getMinutes() that returns the minutes field of the time. For more information, please follow other related articles on the PHP Chinese website!