How can i add 5 days to the current date, and then convert it to a string representing the local date and time?
const newDate = new Date();
const test = newDate.setDate(newDate.getDate() + 5).toLocaleString();
Just returns the number of milliseconds.. (same if i use toString().
Without using any libraries, Vanilla JS solution:
const now = new Date()
const inFiveDays = new Date(new Date(now).setDate(now.getDate() + 5))
console.log('now', now.toLocaleString())
console.log('inFiveDays', inFiveDays.toLocaleString())
This even works when your date overflows the current month.
Just use new Date() in front of it.
const newDate = new Date();
const add =5
const test = newDate.setDate(newDate.getDate() + add)
console.log(new Date(test).toLocaleString());