首页 > Web开发 > 详细

js时间的应用(再看看前面,会发现不一样的)

时间:2019-04-18 19:04:25      阅读:154      评论:0      收藏:0      [点我收藏+]
1、年份(1970-)
获取 date.getFullYear();
设置 date.setFullYear(2016);

2、月份(0-11) 0代表1月
获取 date.getMonth()
设置 date.setMonth(0);//设置月份为1月

3、日(1-31)
获取 date.getDate()
设置 date.setDate(18)//设置日期为18日
 
特殊:设置天为0,存储的是上个月的总天数
date.setDate(0);
date.getDate();//获取上个月的总天数

4、星期(0-6) 0代表周日
获取 date.getDay();

不可设置星期

5、小时(0-23)
获取:date.getHours()
设置:date.setHours(18);

6、分钟(0-59)
获取:date.getMinutes();
设置:date.setMinutes(59);

7、秒(0-59)
获取:date.getSeconds();
设置:date.setSeconds(20);

8、毫秒
获取:date.getMilliseconds();
设置:date.setMilliseconds(890);

get获取 set设置(返回的都是时间戳)

js时间的应用(再看看前面,会发现不一样的)

原文:https://www.cnblogs.com/192-163-0-1/p/10731574.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!