I need to subtract months and days from an entry date, but I have a problem with formatting the result to dd/mm/yyyy
.
My entry is a string: "dd/mm/yyyy"
.
mydateEntry = new Date("2021", Number("04") - 1, "01");
myFirstResult = mydateEntry.setDay(mydateEntry.getDay() - (2 * 7));
mySecondResult = mydateEntry.setMonth(mydateEntry.getMonth() - 3);
console.log({ myFirstResult, mySecondResult });
I’m getting the result like this 1617228000000
.
I tried to format the results using many functions that I found on the DateJS GitHub repo but it is always not working.
I need to format my results to dd/mm/yyyy
.
CodePudding user response:
try this: new Date(mySecondeResult).toLocaleDateString()