当前位置: 移动技术网 > IT编程>开发语言>JavaScript > js时间的应用(再看看前面,会发现不一样的)

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

2019年04月19日  | 移动技术网IT编程  | 我要评论
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设置(返回的都是时间戳)

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网