0

Im having a difficult time, from API im getting data like

{ 
id: 1, 
name: 'name', 
startTime: '1640153700', 
endTime: '1640159100'
},
{ 
id: 2, 
name: 'Name2', 
startTime: '1640153700', 
endTime: '1640159100'
}

startTime and endTime is in Timestamp from API and on Angular Component im printing it as

<div *ngFor="let d of data;let i=index">
<p>{{d.name}}</p>
<p>{{d.startDate *1000 | date:'dd MMM YYYY' }}</p>
</div>

//Component.ts

constructor(
   private _services:ApiService,
) { }

data:any=[];

this._services.data().subscribe((result)=>{
 //console.log(result);
 this.data= result;
})

Instead of Printing the Dates, i want to check if with the startTime is Today or Tomorrow

Tried doing a *ngIf="d.startTime = d.this.todayDate" i dont think this is right

this.todayDate = this.datepipe.transform(this.currentDate, 'dd MMM yyyy');

and bunch of other things that didnt work, Basically, i Need to Check

if startTime is Today, Then print Today,

if startTime is Tomorrow, Then Print Tomorrow

and if current date and time is between startTime and endTime, then Print Live

Bal Sankar
  • 25
  • 1
  • 3
  • try to use [moment](https://stackoverflow.com/questions/35166168/how-to-use-moment-js-library-in-angular-2-typescript-app) for your project, he can condition dates – Никита Середа Dec 22 '21 at 07:39
  • Don't use moment it's deprecated (more [here](https://momentjs.com/docs/#/-project-status/)). You might want to look [here](https://blog.logrocket.com/4-alternatives-to-moment-js-for-internationalizing-dates/) for alternatives – Batajus Dec 22 '21 at 09:56

0 Answers0