【问题标题】:How to specify timezone for date fields in Jqgrid (Guriddo)?如何在 Jqgrid (Guriddo) 中为日期字段指定时区?
【发布时间】:2021-06-01 06:14:03
【问题描述】:

是否有任何选项可以在 Guriddo jqgrid 中为日期字段指定时区,以根据客户端(浏览器)时区显示日期值,如 jstl fmt:timezone?

目前,我正在为日期字段使用以下格式选项。

{ 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' } }

【问题讨论】:

    标签: jqgrid jqgrid-formatter


    【解决方案1】:

    这是可能的,取决于您的需要。

    首先,您的设置 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-18
      • 1970-01-01
      • 2017-02-26
      • 2021-12-07
      • 1970-01-01
      • 2014-01-17
      • 2021-12-06
      相关资源
      最近更新 更多