| | |
| | | let d2 = Date.parse(new Date(endDdate)); |
| | | // 时间戳相减 / 天数 |
| | | let day = parseInt((d2 - d1) / (1000 * 60 * 60 * 24)); |
| | | console.log(day) |
| | | return day |
| | | } |
| | | |
| | | // 获取多少天后的日期 |
| | | export const getDaysAfterDate = (date, days) => { |
| | | if (days === 0) { |
| | | return '2099-01-01' |
| | | } |
| | | const now = new Date(date); |
| | | now.setDate(now.getDate() + days); |
| | | const year = now.getFullYear(); |
| | | const month = now.getMonth() + 1; // 月份是从0开始的 |
| | | const day = now.getDate(); |
| | | return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`; |
| | | } |