Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jqgrid-日期列格式_Jqgrid_Date Format - Fatal编程技术网

Jqgrid-日期列格式

Jqgrid-日期列格式,jqgrid,date-format,Jqgrid,Date Format,以json返回的日期coulmn是1371700800000。我正在尝试将其转换为mm/dd/yyyy格式 我有下面的代码在jqgrid中格式化,但仍然得到日期的值为NaN/NaN/NaN。我使用的是jqgrid版本4.4.1。请帮忙 {name:'inactiveDate',index:'inactiveDate', width:30, formatter:'date', formatoptions: {srcformat:"d/m/Y H:i A", newformat: 'ShortD

以json返回的日期coulmn是1371700800000。我正在尝试将其转换为mm/dd/yyyy格式

我有下面的代码在jqgrid中格式化,但仍然得到日期的值为NaN/NaN/NaN。我使用的是jqgrid版本4.4.1。请帮忙

 {name:'inactiveDate',index:'inactiveDate', width:30, formatter:'date',  formatoptions: {srcformat:"d/m/Y H:i A", newformat: 'ShortDate' },editable:true,edittype:"text",editoptions: {size: 10, maxlengh: 10,dataInit : function (elem) {
                    $(elem).datepicker();
                }}}

我已经通过手动修改jquery.jqgrid.src.js(4.5.2)解决了日期字段的NaN/NaN/NaN问题。 在我的例子中,json响应将以“ISO1860Long”格式返回日期。它一直工作到4.1.2 jqgrid版本

搜索“parseDate”函数;转到以下位置后的线路:

if( opts.masks.hasOwnProperty(format) ) { format = opts.masks[format]; }
if(date && date != null) {
如果选中,则添加以下内容:

if(date.constructor === Number) {
  if(String(format).toLowerCase() == "u") {
    date = date*1000;
  }
  timestamp = new Date(date);
} else
在现有的

if( !isNaN( date - 0 ) && String(format).toLowerCase() === "u") {

如果需要,您可以自己将更改转换为jquery.jqgrid.min.js

日期格式
mm/dd/yyyy
显示在jqgrid中,如
0404/2828/161616
,您应该使用此格式
m/d/y
,并显示为
04/28/16
。单m或d或y就足够了,否则它会重复两次

注意:对于jqGrid中的转换长日期,请在formatoptions函数中提到
U/1000
atsrcformat

代码:

{name:'startDate',index:'startDate',width:120, formatter: 'date', formatoptions: { srcformat: 'U/1000', newformat:'m/d/Y' }},
{name:'startDate',index:'startDate',width:120, formatter: 'date', formatoptions: { srcformat: 'U/1000', newformat:'d-M-Y H:i A' }},
jqGrid列中的输出:
04/28/16

代码:

{name:'startDate',index:'startDate',width:120, formatter: 'date', formatoptions: { srcformat: 'U/1000', newformat:'m/d/Y' }},
{name:'startDate',index:'startDate',width:120, formatter: 'date', formatoptions: { srcformat: 'U/1000', newformat:'d-M-Y H:i A' }},

jqGrid列中的输出:
2016年4月28日08:30 AM

当检查日期为空或定义了其他内容时,我遇到了我直接解决的相同问题,我设置了条件并直接返回函数它工作正常

请转到
parseDate
函数

在此逻辑之前,取消对代码逻辑的理解

如果(日期和日期!=null){