jqgridjqgrid-formatter

How to specify timezone for date fields in Jqgrid (Guriddo)?


Is there any option to specify timezone In Guriddo jqgrid for date fields to show the date value as per client(browser) timezone like jstl fmt:timezone?

Currently, I am using below format options for date field.

{ name : 'approveDate', index : 'approveDate', width : 100,search:true,searchoptions: { dataInit: dateFieldsInit}, editable : false,formatter:'date',formatoptions: {srcformat: 'U/1000', newformat: 'Y-m-d H:i:s' } }

Solution

  • This is possible and depend on your need.

    First of all your setting srcformat: ‘U/1000’ is not correct and Gurddo will not recognize this format. You should perform calculations for the Unix timestamp before to pass the data to jqGrid.

    1.First option is to show the time offset without to inform user about this. This is done with the settings userLocalTime set to true in format options.

    { name : 'approveDate', index : 'approveDate', width : 100,search:true,searchoptions: { dataInit: dateFieldsInit}, editable : false,formatter:'date',formatoptions: {srcformat: 'U', newformat: 'Y-m-d H:i:s', userLocalTime : true } }
    

    2.You can use either the option O or T newformat. In this case userLocalTime should be set to false

    { name : 'approveDate', index : 'approveDate', width : 100,search:true,searchoptions: { dataInit: dateFieldsInit}, editable : false,formatter:'date',formatoptions: {srcformat: 'U', newformat: 'Y-m-d H:i:s O' } }
    

    or

    { name : 'approveDate', index : 'approveDate', width : 100,search:true,searchoptions: { dataInit: dateFieldsInit}, editable : false,formatter:'date',formatoptions: {srcformat: 'U', newformat: 'Y-m-d H:i:s T' } }
    

    The T option give more information.

    Everthing is explained into the documentation