//xx年yy月dd日 hh时mm分ss秒functiontime(date){let time =newDate(date)const year =time .getFullYear();const month = time .getMonth()+1;const date = time .getDate();const hours = time .getHours()const minutes = time .getMinutes();const seconds = time .getSeconds();return year+"年"+month+"月"+date+"日"+hours+"时"+minutes+"分"+seconds+"秒";}
//将毫秒数转化为xx时xx分function(val){let h = Math.trunc((val/(1000*60*60)))//小时let m = Math.trunc((val%(1000*60*60)/(1000*60)))//分钟if(h>0){return`${h}小时${m}分`}else{return`${m}分`}}
//获取一周时间functionaWeek(){var now =newDate();var nowTime = now.getTime();var day = now.getDay();var oneDayTime =24*60*60*1000;//显示周一var MondayTime = nowTime -(day -1)* oneDayTime;//显示周日var SundayTime = nowTime +(7- day)* oneDayTime;//初始化日期时间var monday =newDate(MondayTime);var sunday =newDate(SundayTime);if(monday){const year = monday.getFullYear();const month = monday.getMonth()+1>9?monday.getMonth()+1:`0${monday.getMonth()+1}`;const date = monday.getDate()>9?monday.getDate():`0${monday.getDate()}`;let startTime = year +"-"+ month +"-"+ date +" "+"00"+":"+"00"+":"+"00";
console.log(startTime);}if(sunday){const year = sunday.getFullYear();const month = sunday.getMonth()+1>9?mosundaynday.getMonth()+1:`0${sunday.getMonth()+1}`;;const date = sunday.getDate()>9?sunday.getDate():`0${sunday.getDate()}`;let endTime =year +"-"+ month +"-"+ date +" "+"24"+":"+"00"+":"+"00";
console.log(endTime);}}