可以写在export default的下方
export default{
}
//时间戳转换方法 date:时间戳数字
function formatDate(date) {
var date = new Date(date);
var YY = date.getFullYear() + '-';
var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
return YY + MM + DD +" "+hh + mm + ss;
调用
this.timestart = this.value1[0].getTime(); //当前选择的时间选择 上午时间 初始时间
let strtimeStart = formatDate(this.timestart , 'hh:mm:ss')
data:
ruleForm: {
value1: [new Date(), new Date()],
value2: [new Date(), new Date()],
checkedweek: [],
},