AM/PM date formatting in jqGrid

心已入冬 提交于 2020-01-14 06:59:08

问题


I'm having trouble figuring out where I'm going wrong with this date formatting on jqGrid. I pass in the date formatted by C# as MM/dd/yyyy hh:mm:ss tt which produces 01/20/2012 10:01:26 PM.

In my jqGrid I apply formatting as follows:

colModel: [
...
    { name: 'EndTime', index: 'EndTime', sorttype: 'date', formatter:'date', formatoptions: {srcformat:'m/d/Y h:i:s A', newformat:'m/d/Y h:i:s A'} },
...
],

This is working fine for everything except the AM/PM. It's always showing AM in my grid. From jqGrid's documentation, it looks like this should be the right format. Does anyone see where I'm going wrong?

Thanks!


回答1:


I found a solution. I changed the formatting in C# to yyyy-MM-dd HH:mm:ss and my colModel to formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'm/d/Y h:i:s A' }.

The source format is the ISO8601Long format. I did not use 'ISO8601Long' since I'm using local data and want to sort.



来源:https://stackoverflow.com/questions/9203678/am-pm-date-formatting-in-jqgrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!