JavaScript getUTCHours 函数是 Date 函数之一,它根据通用时间返回给定日期的总小时数。getUTCHours 函数的语法是
Date.getUTCHours()
我正在使用 getUTCHours 根据通用时间从当前日期和时间返回总小时数。
<!DOCTYPE html>
<html>
<head>
<title> JS </title>
</head>
<body>
<h1> Example </h1>
<script>
var dt = Date();
document.write("Date and Time : " + dt);
document.write("UTC Hours : " + dt.getUTCHours());
</script>
</body>
</html>
Example
Date and Time: Mon Nov 05 2018 10:54:43 GMT+0530 (Indian Standard Time)
UTC Hours : 5
在此 JavaScript get UTC Hours 示例中,我们显示了自定义日期的通用时间小时数。
<!DOCTYPE html>
<html>
<head>
<title> JavaScript Get UTC Hours Function </title>
</head>
<body>
<h1> JavaScriptgetUTCHoursFunctionExample </h1>
<script>
var dt = Date("April 2, 2017 10:11:22");
document.write("Date and Time : " + dt);
document.write("UTC Hours using getUTCHours : " + dt.getUTCHours());
</script>
</body>
</html>
