当前位置:
首页 >
前端技术
> 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中的填
- 下一篇: SpringBoot 使用注解实现消息广