JS日期(Date)处理函数总结

来源:互联网 发布:木马源码 编辑:程序博客网 时间:2024/05/19 06:51

获取日期

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 对象。

0 0