const checkTime = function(i) { if (i < 10) { i = "0" + i; } return i; } export const showtime = function() { let nowdate = new Date(); let year = nowdate.getFullYear(), month = checkTime(nowdate.getMonth() + 1), date = checkTime(nowdate.getDate()); // day = nowdate.getDay(), // week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"], // h = nowdate.getHours(), // m = nowdate.getMinutes(), // s = nowdate.getSeconds(), // h = checkTime(h), // m = checkTime(m), // s = checkTime(s); // return year + "年" + month + "月" + date + "日" + week[day] + " " + h + ":" + m + ":" + s; return year + '-' + month + '-' + date; } // 毫秒换算时间 export const timeConsuming = function(time) { let days = parseInt(time / (1000 * 60 * 60 * 24)), hours = parseInt((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)), minutes = parseInt((time % (1000 * 60 * 60)) / (1000 * 60)), seconds = (time % (1000 * 60)) / 1000; if (time >= 86400000) { return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒"; } else if (time >= 3600000) { return hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒"; } else { return minutes + " 分钟 " + seconds + " 秒"; } }