How to assign date to new variable?

Viewed 31

I had take date into a variable like below.

var todayDate = new Date();

After this I am assigning todayDate to another variable:

 var yesterdayDate = todayDate;

 yesterdayDate.setDate(yesterdayDate.getDate() - 1);

After this I am assigning todayDate to another variable:

 var next30daysDate = todayDate;
 next30daysDate.setDate(next30daysDate.getDate() + 29);

How should I keep todayDate constant for above two variables. in my case it is chnging for very variable.

0 Answers
Related