title: How to Compare the future date with current date in angular?
body: <p>Component.ts(Here I would like to compare the date from today greater than expiry date.. I have tried this code.. but it's not working as expected.. could you please help me out??)(Another thing i would like to get the valueofcertificate map into the getAgents array then based on condition i need to change the value of valueofcertificate variable..its is not working properly.. could you please find any mistakes in my code?? thank you in advance)</p>
  
  <pre><code>      getAllAgents() {
      this.agentShowSpinner = true;
      // this.agentSuccessSubscription.unsubscribe()
      // this.agentErrorSubscription.unsubscribe()
      this.store.dispatch(new GetAllAgents(`${this.userService.getUserdetails().CompanyUser.company_id.id}/true`))
      this.agentSuccessSubscription = this.store.pipe(select(getAllAgentsSuccess)).subscribe((result : any) =&gt; {
        if(!!result) {
          this.getAgents = result
          this.getAgents.map(item =&gt; item.valueofCertificate = '')
          this.getAgents.forEach(element =&gt;{
  
            if(element.foodsafetycertificate.length == 0){
              console.log(element.foodsafetycertificate.length)
                element.valueofCertificate = "Certificates Not Available"
                console.log(element.valueofCertificate )
            }
            else{
             element.valueofCertificate = this.getFoodCertificateValues(element)
        }
  
  
          })
          console.log(this.getAgents)
          this.dataSource = new MatTableDataSource(result)
          this.dataSource.paginator = this.paginator;
        }  else {
          this.dataSource = new MatTableDataSource([])
          this.dataSource.paginator = this.paginator;
        }
        this.agentShowSpinner = false
      })
      this.agentErrorSubscription =  this.store.pipe(select(getAllAgentsError)).subscribe((result : any) =&gt; {
        if(!!result) {
          alert(result)
          this.agentShowSpinner = false
        }
      })
    }
  
    getFoodCertificateValues(element: any){// those conditions are not working.. could you help me out?
  
      let now = new Date
      now.setHours(0,0,0,0);
      element.foodsafetycertificate.forEach(item =&gt; {
        if(!item.expiry_date){
          element.valueofCertificate = "Certificates Not Available"
        }
        else if(item.expiry_date  &gt;= new Date(now.setDate(now.getDate()))){
          element.valueofCertificate = "Certificates are Valid"
            }
         else if(item.expiry_date &lt;= new Date(now.setDate(now.getDate()))){
          element.valueofCertificate = "Certificates Expired"
            }
      })
  
  
    }
  </code></pre>