I have a table using Primeng for displaying the table values. In the table there is one column for date, for date the sort option is not working. It is considering as normal string value instead of Date.
From the service getting the date in timestamp format. Using below code in UI to convert the date in required format.
import { DatePipe } from '@angular/common';
constructor(private datePipe: DatePipe) {
}
dateFormat(val: any) {
if (val.toString().indexOf('.') > 0) {
return this.datePipe.transform(new Date(val * 1000), 'd-MMM-y');
} else {
val = val.toString() + '.0000';
return this.datePipe.transform(new Date(val * 1000), 'd-MMM-y');
}
}