JavaScript getMinutes 函数是 Date Functions 之一,用于返回给定日期的分钟数。
以下 getMinutes 函数返回当前日期和时间的总分钟数。
<!DOCTYPE html>
<html>
<head>
<title> JavaScriptGetMinutesFunction </title>
</head>
<body>
<h1> JavaScriptgetMnutesFunctionExample </h1>
<script>
var dt = Date();
document.write("Date and Time : " + dt);
document.write("Minutes from getMinutes(): " + dt.getMinutes());
</script>
</body>
</html>

在这个 get 示例中,我们从自定义日期中提取分钟。
<!DOCTYPE html>
<html>
<head>
<title> JS </title>
</head>
<body>
<h1> Example </h1>
<script>
var dt = Date("April 31, 2012 12:09:07");
document.write("Date and Time : " + dt);
document.write("Minutes : " + dt.getMinutes());
</script>
</body>
</html>
Example
Date and Time: Tue May 01 2012 12:09:07 GMT+0530 (Indian Standard Time)
Minutes : 9
在这个 JavaScript 示例中,我们从没有时间的自定义日期中提取分钟(分钟)。这将返回 0 分钟。
<!DOCTYPE html>
<html>
<head>
<title> JS </title>
</head>
<body>
<h1> Example </h1>
<script>
var dt = Date("April 31, 2012");
document.write("DateTime : " + dt);
document.write("Minutes : " + dt.getMinutes());
</script>
</body>
</html>
Example
DateTime: Tue May 01 2012 00:00:00 GMT+0530 (Indian Standard Time)
Minutes : 0