純jsカウントダウン

1438 ワード

純jsカウントダウン
setInterval(() => {
	var nowalldate = this.data.auto_close_time;
	var Year = nowalldate.slice(0, 4);
	var Month = nowalldate.slice(5, 7);
	var Datea = nowalldate.slice(9, 11);
	var Hoursa = nowalldate.slice(11, 13);
	var Mina = nowalldate.slice(14, 16);
	var Secondsa = nowalldate.slice(17, 19);
	if (Month.slice(0, 1) == 0) {
		Month = Month.slice(1, 2);
	}
	if (Datea.slice(0, 1) == 0) {
		Datea = Datea.slice(1, 2);
	}
	if (Hoursa.slice(0, 1) == 0) {
		Hoursa = Hoursa.slice(1, 2);
	}
	if (Mina.slice(0, 1) == 0) {
		Mina = Mina.slice(1, 2);
	}
	if (Secondsa.slice(0, 1) == 0) {
		Secondsa = Secondsa.slice(1, 2);
	}
	// console.log(nowalldate);
	//    (  )
	var nowDate = new Date();
	//2018     
	var nextDate = new Date(Year, Month, Datea, Hoursa, Mina, Secondsa);
	//          1970.0.1   (   )
	var nowTime = nowDate.getTime();
	var nextTime = nextDate.getTime();
	//              2018             (   /1000)
	var dSecond = parseInt((nextTime - nowTime) / 1000);
	//      2018        (  /24*60*60)
	var dDay = parseInt(dSecond / (24 * 60 * 60));
	//      2018                   
	var reSecond = dSecond % (24 * 60 * 60);
	//                 
	var dHour = parseInt(reSecond / 3600);
	//                 
	var reSecond1 = reSecond % 3600;
	var dMinute = parseInt(reSecond1 / 60);
	this.min = dMinute;
	//                        
	var nowSecond = reSecond1 % 60;
	this.miao = nowSecond;
}, 1000);