In jqGrid how to format timestamp in dd / mm / yyyy format

My application sends timestamp data to jqgrid (like "1268913728759").

Now I want to format it as dd/mm/yyyy .

In jqGrid I added the following line, but didn't work

 {name:'testDate',index:'testDate', width:100, formatter:'date', formatoptions: {srcformat: 'ts',newformat:'d/m/Y'}} 
+6
source share
2 answers

The correct locations for this case should be:

 formatter:'date', formatoptions: {srcformat: 'U', newformat:'d/m/Y'} 

"U" is the format character for "Seconds since Unix Epoch".

+6
source

Try the following:

 formatter: function (cellValue, opts, rwd) { if (cellValue) { return $.fn.fmatter.call(this, "date", new Date(cellValue), opts, rwd); } else { return ''; } } 

The correct locations for this case should be:

 formatter:'date', formatoptions: {srcformat: 'U', newformat:'d/m/Y'} 

"U" is the format character for the "Seconds from the Unix era" format.

A timestamp like "1268913728759" means milliseconds, not seconds after the Unix era

+1
source

Source: https://habr.com/ru/post/901998/


All Articles