I need create column of duration. I have duration in seconds but I need show time by format like 'H:i:s'.
When I use date formatter and have time 60 seconds grid show me value '01:01' but I need only '00:01'.
Is it possible to create duration column in colModel without modify or optimize data?
Maybe use date formatter but auto decrement value -3600.
My column settings are
formatter: date
formatoptions:
srcformat: "U"
"newformat": "H:i:s"
I use the newest version of jqgrid guriddo.
UPDATE: EXAMPLE DATA:
{
"page": 1,
"records": 3,
"rows": [
{
"id": 1,
"name": "FIRST ROW",
"duration": 1139
},
{
"id": 2,
"name": "SECOND ROW",
"duration": 60
},
{
"id": 3,
"name": "THIRD ROW",
"duration": 15336
}
],
"total": 1
}
I see where is the problem. jqGrid gets the local timezone and convert it according to this.
I suggest you to use a custom formatter in this case instead of the build in one. So replace the formatter : date with
formatter : function(val, opt, data ) {
var offset = (new Date( val )).getTimezoneOffset();
return $.jgrid.parseDate.call(this, 'U', (parseFloat(val) + offset*60), 'H:i:s');
}
This way any user from any time zone will see 00:01:00