简介JavaScript中的setHours()方法的使用_基础知识

WBOY
Release: 2016-05-16 15:55:37
Original
1695 people have browsed it

javascript Date.setHours()方法按照本地时间设置小时在指定的日期。
语法

Date.setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])
Copy after login

注:括号内的参数是可选的

下面是参数的详细信息:

  • hoursValue : 0到23之间的整数,代表小时
  • minutesValue :0到59之间的整数,代表分钟
  • secondsValue : 0到59之间的整数,代表秒。如果指定secondsValue参数,则还必须指定minutesValue
  • msValue : 一个数字0和999之间,代表毫秒。如果指定msValue参数,则还必须指定minutesValue和secondsValue

如果不指定 minutesValue,secondsValue 和 msValue 参数,使用getUTCMinutes,getUTCSeconds 和 getMilliseconds方法返回的值
返回值:

  • NA

例子:

  JavaScript setHours Method 
    
Copy after login

这将产生以下结果:

Thu Aug 28 02:30:00 UTC+0530 2008
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!