function checkTime(i) { if (i < 10) { i = "0" + i; } return i; } export function getnowtime() { var nowdate = new Date(); var year = nowdate.getFullYear() var month = nowdate.getMonth() + 1 var date = nowdate.getDate() var day = nowdate.getDay() var week = [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", ] var h = nowdate.getHours() var m = nowdate.getMinutes() var s = nowdate.getSeconds() var h = checkTime(h) var m = checkTime(m) var s = checkTime(s) var month_=checkTime(month) var date_=checkTime(date) return { day:date, year:{year:year,month:month_,date:date_}, week: week[day], time: h + ":" + m , timeS:s } } export function getyesterday(time){ var nowtime=new Date(time).getTime() - 24 * 60 * 60 * 1000; var nowdate = new Date(nowtime); var year = nowdate.getFullYear() var month = nowdate.getMonth() + 1 var date = nowdate.getDate() var day = nowdate.getDay() var week = [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", ] var month_=checkTime(month) var date_=checkTime(date) return { day:date, year:{year:year,month:month_,date:date_}, week: week[day], } } export function getdata(time) { if (!time) { return { days:0, hours:0, minutes:0, seconds:0, }; } var nowdate=new Date(); var lastdate = new Date(time); var alltime=new Date(nowdate-lastdate) var days =Math.floor(alltime/(1000*60*60*24)) var hours= checkTime(Math.floor((alltime%(1000*60*60*24))/(1000*60*60))) var minutes=checkTime(Math.floor(((alltime%(1000*60*60*24))%(1000*60*60))/(1000*60))) var seconds=checkTime(Math.floor((((alltime%(1000*60*60*24))%(1000*60*60))%(1000*60))/1000)) return { days, hours, minutes, seconds, } }