function counter() { var date = new Date(); var year = date.getFullYear(); var date2 = new Date(year, 12, 31, 23, 59, 59); /*转换成秒*/ var time = (date2 - date) / 1000; var day = Math.floor(time / (24 * 60 * 60)) var hour = Math.floor(time % (24 * 60 *…