引言:我们经常使用elementl里的el-date-picker和el-time-picker标签但是有时候有需求需要获取一个完整的年月日分时秒的时候我们的标签就有局限了需要我们手动处理数据
代码
<el-form-item label="检测时间">
<el-col :span="11">
//选择的日期
<el-date-picker type="date" placeholder="选择日期" v-model="forms.tart_time" style="width: 100%;"></el-date-picker>
</el-col>
<el-col class="line" :span="2">-</el-col>
<el-col :span="11">
//选择的时间
<el-time-picker placeholder="选择时间" v-model="forms.tart_time1" style="width: 100%;"></el-time-picker>
</el-col>
</el-form-item>
// data
tart_time:new Date(),
tart_time1:new Date(),
//处理方法
var year = this.tart_time.getFullYear();
var month = this.tart_time.getMonth() + 1;
var strDate = this.tart_time.getDate();
var hh = this.tart_time1.getHours(); //时
var mm = this.tart_time1.getMinutes(); //分
var ss = this.tart_time1.getSeconds();
// console.log(hh,mm,ss)
console.log(new Date(year+'-'+month+'-'+strDate+' '+hh+':'+mm+':'+ss))