zoukankan      html  css  js  c++  java
  • 关于JS Date 时间计算

    倒计时功能Demo:http://play.163.com/special/test-timeending/?1465197963677

    获取时间

    Date() 返回当日的日期和时间。 
    getDate() 从 Date 对象返回一个月中的某一天 (1 ~ 31)。
    getDay() 从 Date 对象返回一周中的某一天 (0 ~ 6)。
    getMonth() 从 Date 对象返回月份 (0 ~ 11)。
    getFullYear() 从 Date 对象以四位数字返回年份。
    getYear() 请使用 getFullYear() 方法代替。
    getHours() 返回 Date 对象的小时 (0 ~ 23)。
    getMinutes() 返回 Date 对象的分钟 (0 ~ 59)。
    getSeconds() 返回 Date 对象的秒数 (0 ~ 59)。
    getMilliseconds() 返回 Date 对象的毫秒(0 ~ 999)。
    getTime() 返回 1970 年 1 月 1 日至今的毫秒数。

    设置时间

    setDate() 设置 Date 对象中月的某一天 (1 ~ 31)。
    setMonth() 设置 Date 对象中月份 (0 ~ 11)。
    setFullYear() 设置 Date 对象中的年份(四位数字)。
    setYear() 请使用 setFullYear() 方法代替。
    setHours() 设置 Date 对象中的小时 (0 ~ 23)。
    setMinutes() 设置 Date 对象中的分钟 (0 ~ 59)。
    setSeconds() 设置 Date 对象中的秒钟 (0 ~ 59)。
    setMilliseconds() 设置 Date 对象中的毫秒 (0 ~ 999)。
    setTime() 以毫秒设置 Date 对象。

    将日期对象设置为 5 天后的日期:

    var myDate=new Date()
    myDate.setDate(myDate.getDate()+5)
  • 相关阅读:
    【leetcode】1009. 十进制整数的反码
    【leetcode】1446. 连续字符
    __getattr__在python2.x与python3.x中的区别及其对属性截取与代理类的影响
    Python 中异常嵌套
    python 变量搜寻顺序法则LEGB之E注意事项
    %%的一个应用
    python中__str__与__repr__
    052-180
    052-177
    052-176
  • 原文地址:https://www.cnblogs.com/huangxiaowen/p/5563966.html
Copyright © 2011-2022 走看看