當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
gethours_日期getHours()方法以及JavaScript中的示例
生活随笔
收集整理的這篇文章主要介紹了
gethours_日期getHours()方法以及JavaScript中的示例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
gethours
JavaScript Date getHours()方法 (JavaScript Date getHours() method)
getHours() method is a Date's class method and it is used to get the only hours from current time.
getHours()方法是Date的類方法,用于獲取距當前時間僅有的小時數。
It accepts nothing as the parameter and returns a value between 0 to 23.
它不接受任何參數作為參數,并返回0到23之間的值。
Syntax:
句法:
var dt = new Date();dt.getHours();Examples:
例子:
Input:var dt = new Date();dt.getHours();Output:19 (if the time is 19:any_minutes:any_seconds)JavaScript code to get the hours only from the current time using getHours() method
JavaScript代碼使用getHours()方法僅從當前時間獲取小時數
<html> <head><title>JavaScipt Example</title></head><body> <script>var dt = new Date(); //Date constructor var hours = dt.getHours(); //getting hours from current time//printing hourdocument.write("Current hour is : " + hours); </script> </body> </html>Output
輸出量
Current hour is : 19翻譯自: https://www.includehelp.com/code-snippets/date-getHours-method-with-example-in-javascript.aspx
gethours
總結
以上是生活随笔為你收集整理的gethours_日期getHours()方法以及JavaScript中的示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: js中的转译_JavaScript中的填
- 下一篇: 用Netty撸一个心跳机制和断线重连!