标签:form add 日期 OLE ons date spl 电商 end
// 时间选择转换
getFormat(date){
let weekList = [‘星期日‘,‘星期一‘,‘星期二‘,‘星期三‘,‘星期四‘,‘星期五‘,‘星期六‘]
let YYYY = date.getFullYear()+‘-‘
let MM = (date.getMonth()+1 < 10 ? ‘0‘+(date.getMonth()+1) : date.getMonth()+1) + ‘-‘;
let DD = date.getDate();
if(DD<=9){
DD = ‘0‘+DD+‘‘
}
let newweek = weekList[date.getDay()]
// return (date+‘(‘+newweek+‘)‘)
return (YYYY+MM+DD+‘(‘+newweek+‘)‘)
},
computedTime (start,end){
let oneday = 86400000
let weList =[]
let strCuo = new Date(start).getTime()-oneday
let endCuo = new Date(end).getTime()
let dayNum = (endCuo-strCuo)/oneday //几天
for(var i =0; i < dayNum; i++){
strCuo += oneday
var addDate = new Date(strCuo)
weList.push(this.getFormat(addDate))
}
console.log(weList);
return weList
},
var items= [ "2020 12 20 08:10:35",
"2020 12 20 11:06:01",
"2021 01 24 00:00:00",
"2021 01 24 03:00:00",
"2021 01 24 04:00:00"];
function test(){
let dateFlag = "";
for (var i =0;i<this.items.length;i++) {
var strs = this.items[i].split(" ");
if (dateFlag === strs[0]+strs[1]+strs[2]) {
this.items[i]=strs[3]
}
dateFlag = strs[0]+strs[1]+strs[2]
console.log(dateFlag)
}
console.log(this.items)
}
test();
上面demo输出结果:
大多情况就是将时间格式转为想要的格式再字符拼接~~
标签:form add 日期 OLE ons date spl 电商 end
原文地址:https://www.cnblogs.com/pipigao/p/14654665.html