【问题标题】:In jqGrid, how to format timestamp to dd/mm/yyyy format在 jqGrid 中,如何将时间戳格式化为 dd/mm/yyyy 格式
【发布时间】:2011-11-21 12:45:16
【问题描述】:

我的应用程序将时间戳数据发送到jqgrid (like "1268913728759").

现在我想将其格式化为dd/mm/yyyy

jqGrid 我添加了以下行,但它不起作用

{name:'testDate',index:'testDate', width:100, formatter:'date', formatoptions: {srcformat: 'ts',newformat:'d/m/Y'}}

【问题讨论】:

标签: jqgrid


【解决方案1】:

这个案例的正确设置应该是这样的:

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

“U”是“自 Unix 纪元以来的秒数”日期格式的格式字符。

【讨论】:

  • 您能否在问题中添加一些 JSON 以进行测试?
【解决方案2】:

试试这个:

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

这个案例的正确设置应该是这样的:

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

“U”是“自 Unix 纪元以来的秒数”日期的格式字符 格式。

像“1268913728759”这样的时间戳表示自 Unix 纪元以来的毫秒而不是秒

【讨论】:

  • 嗨,您找到解决方案了吗?我也面临同样的情况。
猜你喜欢
  • 1970-01-01
  • 2018-08-15
  • 2013-03-09
  • 2013-09-21
  • 2021-04-19
  • 1970-01-01
  • 2017-07-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多