I am getting getdate is not a function in ngbdatepicker in typescript

197 Views Asked by At

Below is the code to get the date range between start and end date but when the array is returned getDate is not a function error is consoled

  checkdate(dt){
    let dtdates=new Date(dt);
    dtdates.setDate(dt.getDate() + 1);
    return dtdates
  }
  getDates(pstart1,pend2){
    
    console.log(pstart1);
    console.log(pend2);
    
    let dt:Date= pstart1
    console.log(dt);
    
    while(dt<=pend2){
      this.dates.push(dt);
      dt=this.checkdate(dt) 
      console.log(this.dates)
    }
   
    return this.dates;
  }

Am I missing something here?

1

There are 1 best solutions below

1
Miigon On
dtdates.setDate(dtdates.getDate() + 1);

This is probably what you want to do.