1、计算两个日期之间相差几年、几月、几日,封装函数
/**
* 计算 当前时间 和传入时间 间隔 几年几月几日, 并返回相应格式
* @param val
*/
export function setCompareRegistrationTimeText(startDate, endDate) {
// if (!val) {
// this.ruleForm.compareRegistrationTimeText = '--'
// return
// }
const date = new Date(startDate) // 转换时间格式
const year = date.getFullYear() // 取当年的年
const month = date.getMonth() + 1 // 取当年的月(月份加一)
const dd = date.getDate() // 取当年的日期
const nowDate = new Date(endDate) // 取现在的时间
const nowYear = nowDate