Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the previous date in angular?

Tags:

javascript

Please help me getting the previous dates in angular 4.

currentdate: Date;
this.currentdate = new Date();
console.log(this.datePipe.transform(this.currentdate, 'yyyy-MM-dd'));

Here I got the date as 2017-11-13.

Now I need to get 2 days before date..

like image 393
sasi Avatar asked Nov 13 '17 08:11

sasi


Video Answer


1 Answers

Try this

let dte = new Date();
dte.setDate(dte.getDate() - 2);
console.log(dte.toString());
like image 75
Saurabh Agrawal Avatar answered Oct 06 '22 10:10

Saurabh Agrawal