Reputation: 3241
My application send timestamp data to jqgrid (like "1268913728759").
now i want to format it like dd/mm/yyyy
.
In jqGrid
I added following line but it doesn't worked
{name:'testDate',index:'testDate', width:100, formatter:'date', formatoptions: {srcformat: 'ts',newformat:'d/m/Y'}}
Upvotes: 7
Views: 12134
Reputation: 11
Try this:
formatter: function (cellValue, opts, rwd) {
if (cellValue) {
return $.fn.fmatter.call(this, "date", new Date(cellValue), opts, rwd);
} else {
return '';
}
}
The correct seetings for this case should be like this:
formatter:'date', formatoptions: {srcformat: 'U', newformat:'d/m/Y'}
The 'U' is format character for 'Seconds since the Unix Epoch' date format.
The timestamp like "1268913728759" means milliseconds not seconds since the Unix Epoch
Upvotes: 1
Reputation: 24125
The correct seetings for this case should be like this:
formatter:'date', formatoptions: {srcformat: 'U', newformat:'d/m/Y'}
The 'U' is format character for 'Seconds since the Unix Epoch' date format.
Upvotes: 7