之前:
之后:
之前我是在html中试着调ts中的方法,保存之前整个界面都没了,虽然你挺难看的但是这也太给面子了;屡试无效那就请我们家欢哥来吧(明智之举),欢哥帮我解决完问题还特别好的告诉我model和数组的区别,嘻嘻——一不小心小白的本性暴露了,上面呐废话说完了,上一下demo
<td >
<!--<span (showTime)="convertToDate({{examInfo.examinationEntity.startingDate}})"></span>-->
<li >
{{examInfo.examinationEntity.startingDate}}
---
{{examInfo.examinationEntity.endingDate}}
</li>
</td>
this.dataservice.getExamInfoByStudentId(this.url).subscribe(
res => {
this.examInfoModel = res['data'];
this.examInfoModel.forEach(x=>{
x.examinationEntity.endingDate = this.convertToDate(x.examinationEntity.endingDate);//方法调用converToDate()
x.examinationEntity.startingDate = this.convertToDate(x.examinationEntity.startingDate);
})
console.log(this.examInfoModel);
console.log("this.exampaper---"+this.examInfoModel.forEach.prototype)
})
}
}
convertToDate(nows ){
// return new Date(parseInt(date)*1000).toLocaleString().replace(/:d{1,2}$/,'')
//return new Date(parseInt(date)*1000).toLocaleString().replace(/年|月/g,"-").replace(/日/g,' ')
var now=new Date(nows);
var year=now.getFullYear();
var month=now.getMonth()+1;
var date=now.getDate();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
return year+"年"+month+"月"+date+"日 "+hour+":"+minute+":"+second;
}