I've tried evaluating an epoch with another epoch using <
but it always returns true or false, which is wrong. I converted them both to dates, but the same issue happens where its all either true or false based on if I use <
or >
Some are should be true and some should be false.
auctionHasEnded(auctionEndDate: Date) {
let date: Date;
date = new Date();
return new Date(auctionEndDate) < date;
}
<td [ngStyle]="{'width': '55%'}" id="dateReceived" class="tableStyle" mat-cell *matCellDef="let row">
<span id="endDateTimeLabel" [ngStyle]="{'color':row.auctionEndDateTime > this.today ? 'red' : 'green' }">
{{auctionHasEnded(row.auctionEndDateTime)}}</span></td>
</ng-container>
auctionEndDateTime examples from JSON response: 1576779848, 1577379500, 1578069935, 1577999303
If I have an epoch, how can I evaluate it? I thought converting it to a date and comparing it to a new Date() would be the way to go, but it doesn't seem to evaluating correctly. I appreciate any help.
In order to check the times you can convert today time to epoch just like that:
this.today = +(new Date()/1000) // divide by 1000 to get seconds
1576779848 < this.today // true
Date in JS is by milliseconds as you can see here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.