js计算天数

        var endTime = new Date('2019-12-23 23:59:59').getTime() / 1000 - parseInt(new Date().getTime() / 1000);
        this.timeDay = parseInt(endTime / 60 / 60 / 24);        //相差天数
        endTime = endTime - this.timeDay * 60 * 60 * 24;
        this.timeHour = parseInt(endTime / 60 / 60);            //相差小时
        endTime = endTime - this.timeHour * 60 * 60;
        this.timeMinutes = parseInt(endTime / 60);              //相差分钟

 

你可能感兴趣的:(js脚本)