I have date object:
dateObj = new Date(year, month, date[, hours, minutes, seconds, ms] )
How to get dateObj - 1 day ?
Just like this: moment(). subtract(1, 'days') . It will give you the previous day with the same exact current time that is on your local pc.
How do you get yesterdays' date using JavaScript? We use the setDate() method on yesterday , passing as parameter the current day minus one. Even if it's day 1 of the month, JavaScript is logical enough and it will point to the last day of the previous month.
dateObj.setDate(dateObj.getDate()-1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With