Does anybody know of an easy way of taking a date (e.g. Today) and going back X days?
So, for example, if I want to calculate the date 5 days before today.
Does anybody know of an easy way of taking a date (e.g. Today) and going back X days?
So, for example, if I want to calculate the date 5 days before today.
without using the second variable, you can replace 7 for with your back x days
let d=new Date(new Date().getTime() - (7 * 24 * 60 * 60 * 1000))
You can using Javascript.
For PHP,
Hope it will help you.
split your date into parts, then return a new Date with the adjusted values
Remember that the months are zero based, but the days are not. ie new Date(2009, 1, 1) == 01 February 2009, new Date(2009, 1, 0) == 31 January 2009;