JQGrid日期格式 [英] JQGrid Date Formatting

查看:199
本文介绍了JQGrid日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery JQGrid插件,版本3.8.2,并且无法找出如何格式化日期/时间进行显示。日期/时间采用ISO长格式,即2011-02-16T14:46:43Z。我想以mm / dd / yy H:m:s格式显示。这是我当前的代码,这不起作用:

I am using the jQuery JQGrid plug-in, version 3.8.2 and am having trouble trying to figure out how to format a date/time for display. The date/time comes in ISO long format, i.e. 2011-02-16T14:46:43Z. I want it shown in mm/dd/yy H:m:s format. Here is my current code, which does not work:

currOption.formatoptions = {
  srcformat: 'Y-m-dQH:i:sZ',
  newformat: 'm/d/Y g:i A'
};

请注意,我有一个Q,因为如果我使用T,它会爆炸(这是有道理的,因为T在PHP日期格式中有意义)。

Note that I have a "Q" in there because if I use "T", it blows up (which makes sense, as "T" has meaning in PHP date formatting).

任何人都可以帮助我找出如何正确地执行此格式?

Can anyone help me figure out how to properly do this formatting?

推荐答案

原来你必须省略T和Z才能正确读取入站日期/时间。此代码的作用如下:

Turns out that you have to leave out the "T" and "Z" to make it read the incoming date/times properly. This code works:

currOption.formatoptions = {
    srcformat: 'Y-m-d H:i:s',
    newformat: 'n/j/Y g:i A'
};

我希望这能帮助遇到同样问题的其他人!

I hope this helps others who encounter the same problem!

这篇关于JQGrid日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆