开发者

JQGrid Date Formatting

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 lon开发者_如何学编程g 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'
};

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?


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!


Have you tried this instead?

{srcformat: "ISO8601Long", newformat: 'd/m/Y H:i'}


The jqGrid wiki says to use datefmt:'mm/dd/yyyy'. Have you tried that ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜