博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
日期setHours()方法以及JavaScript中的示例
阅读量:2533 次
发布时间:2019-05-11

本文共 907 字,大约阅读时间需要 3 分钟。

JavaScript Date setHours()方法 (JavaScript Date setHours() method)

setHours() method is a Date class method, it is used to set the hour to the Date object with a valid hour value (between 00 to 23).

setHours()方法是Date类方法,用于将小时设置为具有有效小时值(介于00到23之间)的Date对象。

Note: Hour value larger than the 23 will be truncated from the starting hour value (0), for example, we are going to set 26 as an hour value, it will be truncated as 2.

注意:大于23的小时值将从开始的小时值(0)开始被截断,例如,我们将26设置为小时值,它将被截断为2。

Syntax:

句法:

var dt = new Date();    dt.setHours(hour);

Examples:

例子:

Input/Date class object declaration:    var dt = new Date();    Function call to set the hour:    dt.setHours(16);    Function call to get the hour:    dt.getHours();         Output:    16

JavaScript code to demonstrate an example of Date.setHours() method

JavaScript代码演示Date.setHours()方法的示例

JavaScipt Example

Output

输出量

hour: 19hour: 16hour: 2

Reference:

参考:

翻译自:

转载地址:http://dfazd.baihongyu.com/

你可能感兴趣的文章
DOM笔记2
查看>>
ZOJ 2412 Farm Irrigation(DFS 条件通讯块)
查看>>
Apple Watch视频教程(连载)
查看>>
通过WriteProcessMemory改写进程的内存
查看>>
How Clang handles the type / variable name ambiguity of C/C++
查看>>
初学者浅度剖析eShopOnContainers 里面用到的MediatR .
查看>>
flot中文详解
查看>>
Spark API编程动手实战-08-基于IDEA使用Spark API开发Spark程序-01
查看>>
2014年10月27日
查看>>
转  表空间占用
查看>>
ubuntu下jdk环境变量的设置
查看>>
honeywell1900扫描枪的使用说明
查看>>
MySQL目录结构和简单指令
查看>>
网络编程应用:基于TCP协议【实现文件上传】--练习
查看>>
Func<T, TResult> Delegate
查看>>
Base64编码与解码
查看>>
win下编译ffmpeg库,Compile and build ffmpeg library and dll on Windows x64( 正版)
查看>>
使用 Mailgun 实现 带附件的Email 发送功能
查看>>
哈希索引
查看>>
MemSQL start[c]up Round 1.E
查看>>