这是可能的,取决于您的需要。
首先,您的设置 srcformat: ‘U/1000’ 不正确,Gurddo 将无法识别此格式。在将数据传递给 jqGrid 之前,您应该计算 Unix 时间戳。
1.第一个选项是在不通知用户的情况下显示时间偏移。这是通过在格式选项中将 userLocalTime 设置为 true 来完成的。
{ 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.您可以使用选项 O 或 T newformat。在这种情况下,userLocalTime 应该设置为 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' } }
或
{ 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' } }
T 选项提供更多信息。
一切都解释到documentation