ar time = new Date();// 日期對(duì)象
1.Date() 返回當(dāng)前的日期和時(shí)間;
2.console.log(time.getDate()) 查看Date對(duì)象并返回日期(1—31);
3.console.log(time.getDay()) 返回星期幾(0—6);//0代表周日
4.console.log(time.getHours()) 返回小時(shí)數(shù)(0—23);
5.console.log(time.getMinutes()) 返回分鐘數(shù)(0—59);
6.console.log(time.getMonth()+1) 返回月份值(從0開始,+1);// 0代表1月份,11代表12月份
7.console.log(time.getSeconds()) 返回秒數(shù);
8.console.log(time.getTime()) 返回毫秒數(shù);//從1700年1月1日開始到現(xiàn)在的毫秒數(shù)
9.console.log(time.getYear()) 返回年份 //從1900年開始,要加上1900昆雀,一般不用
10.console.log(time.getFullYear())方法來操作(完整格式 如2015)
傳參的幾種類型:
1.var time = new Date(2015憨颠,11厂置,31早抠,23谣拣,50囚痴,50);//傳參設(shè)置時(shí)間叁怪,年月日,時(shí)分秒深滚,毫秒
console.log(time)
2.var time2 = new Date('june 23,2015,22:15:32');
3.var time3 = time.getTime();