setDate() is using current date as basis instead of desired object

I’m trying to add days to a Date object, but the output is not as desired:

// THIS IS JUST A SIMPLIFIED EXAMPLE.

let date = new Date(01/01/2019 00:00:00)
let finalDate = new Date()

finalDate.setDate(date.getDate() + 10)

console.log(finalDate)
Desired output:
11/01/2019 00:00:00

Actual output:
31/08/2019 13:06:30

It’s using the current system date as a base and setting it to finalDate. which is not what I’m looking for.

20 thoughts on “setDate() is using current date as basis instead of desired object”

Leave a Comment