前端两三问
程序员文章站
2022-05-18 20:49:59
1、js 获取当前日期星期几 getWeek(time) { let weekDay = ["周日","周一", "周二", "周三", "周四", "周五", "周六"]; let myDate = new Date(Date.parse(time)); return weekDay[myDate ......
1、js 获取当前日期星期几
getweek(time) { let weekday = ["周日","周一", "周二", "周三", "周四", "周五", "周六"]; let mydate = new date(date.parse(time)); return weekday[mydate.getday()] }, console.log(getweek('2019-09-11') // 周三
2、iveiw 时间限制今天之前不可选
<date-picker type="date" :options="pickeroptionsstart" ></date-picker> pickeroptionsstart: { disableddate (time) { return time.gettime() < new date(new date().tolocaledatestring()).gettime(); } }
3、js 计算某个时间 前 15天 后15天
function getdatestr(adddaycount, date, type) { var dd = new date(date); dd.setdate(dd.getdate()+adddaycount); var y = dd.getfullyear(); var m = (dd.getmonth()+1)<10?"0"+(dd.getmonth()+1):(dd.getmonth()+1); var d = dd.getdate()<10?"0"+dd.getdate():dd.getdate(); if(type){ if(date === this.oldtime) { return '今天' } else { return d } } else { return y + "-" + m + "-" + d; } } getdatestr(-14, '2019-09-12') // 2019-08-29 getdatestr(14, '2019-09-12') // 2019-09-26