Recently, I encountered an issue with my Ionic mobile application. It has a search button and filter feature that works well for filtering words. However, the problem arises when it comes to filtering dates displayed in the app as timestamps using Angular date filter:
<p>at {{item.fromDate | date:'mediumDate'}}</p>
Here is an image to help you understand the situation:
https://i.sstatic.net/MptYV.jpg
The data displayed includes Unix timestamps for fromDate and toDate.
https://i.sstatic.net/N2Tsz.jpg
I am struggling to implement a search feature for dates due to them being timestamps. Below is the code snippet for the filter function:
getItems(ev: any) {
console.log("awdaw");
console.log("awdaw",this.ListOfitems);
console.log("otin");
this.ListofItems();
let val = ev.target.value;
if (val && val.trim() != '') {
this.ListOfitems = this.ListOfitems.filter((ListOfitem) => {
return (ListOfitem.fromAddress.toLowerCase().indexOf(val.toLowerCase()) > -1||
ListOfitem.toAddress.toLowerCase().indexOf(val.toLowerCase()) >-1) ;
})
}
}