How to subtract two angularjs date variables

后端 未结 7 1090
说谎
说谎 2020-12-01 21:53

I am fairly new to angularjs, but here it goes. I am able two dates through angularjs in the form dd/mm/yyyy, but what I need to do is somehow subtract the two

7条回答
  •  情歌与酒
    2020-12-01 22:40

    you simply convert date into timestamp and then subtract.

    var Date1 = 08/16/2004;
    var Date2= 10/24/2005;
    
    var timestamp1 = new Date(Date1).getTime();
    var timestamp2 = new Date(Date2).getTime();
    
    var diff = timestamp1 - timestamp2
    
    
    var newDate = new Date (diff);
    

提交回复
热议问题