zoukankan      html  css  js  c++  java
  • JS日期(Date)处理函数总结

    获取日期

    1、Date()

    ——返回当日的日期和时间。

    2、getDate()

    ——从 Date 对象返回一个月中的某一天 (1 ~ 31)。

    3、getDay()

    ——从 Date 对象返回一周中的某一天 (0 ~ 6)。

    4、getMonth()

    ——从 Date 对象返回月份 (0 ~ 11)。

    5、getFullYear()

    ——从 Date 对象以四位数字返回年份。

    6、getYear()

    ——请使用 getFullYear() 方法代替。

    7、getHours()
    ——返回 Date 对象的小时 (0 ~ 23)。

    8、getMinutes()

    ——返回 Date 对象的分钟 (0 ~ 59)。

    9、getSeconds()

    ——返回 Date 对象的秒数 (0 ~ 59)。

    10、getMilliseconds()

    ——返回 Date 对象的毫秒(0 ~ 999)

    11、getTime()

    ——返回 1970 年 1 月 1 日至今的毫秒数。

    设置日期

    1、setDate()

    ——设置 Date 对象中月的某一天 (1 ~ 31)。

    2、setMonth()

    ——设置 Date 对象中月份 (0 ~ 11)。

    3、setFullYear()

    ——设置 Date 对象中的年份(四位数字)。

    4、setHours()

    ——设置 Date 对象中的小时 (0 ~ 23)。

    5、setMinutes()

    ——设置 Date 对象中的分钟 (0 ~ 59)。

    6、setSeconds()

    ——设置 Date 对象中的秒钟 (0 ~ 59)。

    7、setMilliseconds()

    ——设置 Date 对象中的毫秒 (0 ~ 999)。

    8、setTime()

    ——以毫秒设置 Date 对象。

  • 相关阅读:
    基于erlang的mud游戏引擎开发
    生成数据库所有表的查询语句
    查找表字段语句
    基础算法总结 Java 版
    ArrayList源码学习
    云服务器安装 Mysql 5.7
    n个元素进栈,共有多少种出栈顺序?
    MyBatis 学习
    Spring学习笔记之AOP
    原来你是这样的 IntegerCache
  • 原文地址:https://www.cnblogs.com/lidgblogs/p/4148906.html
Copyright © 2011-2022 走看看