2
/Date(1352658600000)/ 

日付を表示する場合 日付が正しい形式で表示されません。

適切に変換する方法はFormat(dd/mm/yyyy)

4

2 に答える 2

6

変換を行うために必要なのはdate、jqGrid列モデルでフォーマッターを設定することだけです。

$('#gridId').jqGrid({
    ...
    colModel: [
        ...
        { name: 'Column Name', index: 'Column Index', ..., formatter: "date", formatoptions: { newformat: "m/d/Y"} },
        ...
    ],
    ...
});

オプションの場合、newformatjqGridはPHPの日付フォーマットをサポートします。

于 2012-11-30T12:03:41.997 に答える
1

ここで受け入れられた回答から取得 - Converting json results to a date

文字列から数値を抽出し、それを Date コンストラクターに渡す必要があります。

var x = [ {"id":1,"start":"\/Date(1238540400000)\/"}, {"id":2,"start":"\/Date(1238626800000)\/"} ];

var myDate = new Date(x[0].start.match(/\d+/)[0] * 1));

パーツは次のとおりです。

x[0].start                                - get the string from the JSON
x[0].start.match(/\d+/)[0]                - extract the numeric part
x[0].start.match(/\d+/)[0] * 1            - convert it to a numeric type
new Date(x[0].start.match(/\d+/)[0] * 1)) - Create a date object
于 2012-11-30T11:29:23.810 に答える