/Date(1352658600000)/
日付を表示する場合 日付が正しい形式で表示されません。
適切に変換する方法はFormat(dd/mm/yyyy)
?
/Date(1352658600000)/
日付を表示する場合 日付が正しい形式で表示されません。
適切に変換する方法はFormat(dd/mm/yyyy)
?
変換を行うために必要なのはdate
、jqGrid列モデルでフォーマッターを設定することだけです。
$('#gridId').jqGrid({
...
colModel: [
...
{ name: 'Column Name', index: 'Column Index', ..., formatter: "date", formatoptions: { newformat: "m/d/Y"} },
...
],
...
});
オプションの場合、newformat
jqGridはPHPの日付フォーマットをサポートします。
ここで受け入れられた回答から取得 - 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