Subtracting 30 days from a given date in Javascript

Asked

Viewed 890 times

1

How do I subtract thirty days from a given date, assuming in the field DT_VENC it informs the date of a maturity and in the field DT_AVISO return the date 30 days before the informed, in the format dd/mm/aaaa?

  • yeah, duplicate, but the answer there is equally bad the ones that tried to give here.

  • I put an answer that gives the correct values in the other question. It would be nice if someone took a look, because without any vote people will end up using the incorrect answer that is accepted there.

  • Oops, that’s right! Thank you.

1 answer

-3

 var DT_VENC = new Date();
 var DT_AVISO = new Date().setDate(DT_VENC.getDate() - 30).toLocaleString("pt-BR");`

Browser other questions tagged

You are not signed in. Login or sign up in order to post.