After selecting a date from a vuetify date picker, I am attempting to reformat it as MM/DD/YYYY with an additional year and one less day. For example, January 1, 2022 should display as December 31, 2022. However, the code snippet I've written for this purpose is not functioning as expected:
formatDateNextYear(date) {
if (!date) return null
let a = new Date(date);
a.setDate(a.getDate() - 1)
a.setFullYear(a.getFullYear+1)
const [year, month, day] = a.split('-')
return `${month}/${day}/${year}`
}
The issue lies in the fact that the year isn't being added correctly and the formatting is inaccurate.