Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get Previous Day?

Tags:

javascript

I have date object:

 dateObj = new Date(year, month, date[, hours, minutes, seconds, ms] ) 

How to get dateObj - 1 day ?

like image 835
Bdfy Avatar asked May 11 '11 07:05

Bdfy


People also ask

How do you get previous day in the moment?

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 can I get yesterday's date?

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.


1 Answers

dateObj.setDate(dateObj.getDate()-1); 
like image 195
Billy Moon Avatar answered Oct 02 '22 20:10

Billy Moon