angular-generic-table
angular-generic-table copied to clipboard
How to format the date in data grid ?
How to format date in generic table below native javascript approach is not working ?
format i am getting from backend '1506530292'
{
name:'Ticket Opened',
objectKey:'ticketOpened',
render: function(row){ this.formatDate(row.ticketOpened)},
}
formatDate(date) {
var monthNames = [
"January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
];
var day = date.getDate();
var monthIndex = date.getMonth();
var year = date.getFullYear();
return day + ' ' + monthNames[monthIndex] + ' ' + year;
}
hi @Syedgit, i suggest you to use a Pipe instead, it worked for me this approach,
constructor(private datePipe: DatePipe)
and then in the configObject.fields you could have something like this:
{ name: 'DATE',
objectKey: 'accountDate',
render: (row) => {
if (row.accountDate != null)
return this.datePipe.transform(row.accountDate, 'MM/dd/yyyy');
return ''
},
},
i hope this works for you, greetings
Any Date picker using this table? or any option to select the date?
@sahilkatia perhaps you could elaborate a little on what you want to do? If you want to be able to select a date you could look at using a custom component, perhaps together with this datepicker?