使用
uni.$u.timeFormat
方法将时间戳转为正常日期格式即可。
https://www.uviewui.com/js/time.html#timeformat-date-timestamp-format-yyyy-mm-dd
<!-- 入境时间 -->
<u-datetime-picker
:show="showRjsj"
@cancel="showRjsj = false"
@confirm="rjsjSelect"
v-model="rjsjOption"
mode="date">
</u-datetime-picker>
// 入境时间选择
rjsjSelect(e) {
const timeFormat = uni.$u.timeFormat;
console.log(timeFormat(e.value, 'yyyy-mm-dd'));
console.log(timeFormat(e.value, 'yyyy-mm-dd hh:MM'));
console.log(timeFormat(e.value, 'yyyy-mm'));
this.dataForm.entrydate = timeFormat(e.value, 'yyyy-mm-dd');
this.showRjsj = false;
console.log(this.dataForm.entrydate);