Does anybody know of a simple way of taking a date (e.g. Today) and going back X days, X months and X years?
I have tried that:
var date = new Date()
I have a simpler answer, which works perfectly for days; for months, it's +-2 days:
let today=new Date(); const days_to_subtract=30; let new_date= new Date(today.valueOf()-(days_to_subtract*24*60*60*1000));
You get the idea - for months, multiply by 30; but that will be +-2 days.