Nodejs Date Different diffDate(d2)

Here you can find the source of diffDate(d2)

Method Source Code

Number.prototype.diffDate=function(d2){

      var d1=this;
      var diff1=new Date(d1.dateFormat()).getTime();
      var diff2=new Date(Number(d2).dateFormat()).getTime();
      var msdiff=Math.abs(diff1-diff2);
      var daysDiff=Math.floor(msdiff/(1000*60*60*24));
      return daysDiff;
}

Related

  1. diffDays(date)
    Date.prototype.diffDays = function (date) {
        var diffMs = (this.getTime() - date.getTime()); 
        return Math.round(diffMs / 86400000);
    };
    
  2. diffHours(date)
    Date.prototype.diffHours = function (date) {
        var diffMs = (this.getTime() - date.getTime()); 
        return Math.round(diffMs / 3600000); 
    };
    
  3. diffMinutes(date)
    Date.prototype.diffMinutes = function (date) {
        var diffMs = (this.getTime() - date.getTime()); 
        return Math.round(diffMs / 60000); 
    };
    
  4. diffSeconds(date)
    Date.prototype.diffSeconds = function (date) {
        var diffMs = (this.getTime() - date.getTime()); 
        return Math.round(diffMs / 1000);
    };