How to convert the format of time in a certain behavior of el-table

 1. The billing date is displayed as year, month, day, hour, minute, and second

<el-table-column prop="Date" label="开单日期"  :formatter='dateFormat'></el-table-column>

2. Conversion method

	const dateFormat = function(row:any,col:any){
					 // 获取单元格数据
					      let data = row[col.property];
					          if(data){
					              const dateMat= new Date(data);
					              const Y = dateMat.getFullYear()+ "-";
					              const M = (dateMat.getMonth() + 1)<10?'0'+(dateMat.getMonth() + 1)+ "-":(dateMat.getMonth() + 1)+ "-";
					              const D = dateMat.getDate()<10?'0'+dateMat.getDate()+ " ":dateMat.getDate()+ " ";
								  const H = dateMat.getHours() < 10 ? "0" + dateMat.getHours()+ ":" : dateMat.getHours()+ ":" ;
								  const m = dateMat.getMinutes() < 10 ? "0" + dateMat.getMinutes()+ ":"  : dateMat.getMinutes()+ ":" ;
								  const s=  dateMat.getSeconds() < 10 ? "0" + dateMat.getSeconds() : dateMat.getSeconds();
					              return Y+M+D+H+m+s;
					          }
			}

Guess you like

Origin blog.csdn.net/guapilixianghe/article/details/127025978