2
/Date(1352658600000)/ 

When Display the date Date is not Display in Proper Format.

How to convert in to proper Format(dd/mm/yyyy)?

Narendra Jadhav
  • 10,052
  • 15
  • 33
  • 44
Vipul Malani
  • 21
  • 1
  • 4

2 Answers2

7

All you need to make the conversion is setting date formatter in jqGrid colum model:

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

For the newformat option jqGrid supports PHP date formatting.

tpeczek
  • 23,867
  • 3
  • 74
  • 77
1

Taken from the accepted answer here - Converting json results to a date

You need to extract the number from the string, and pass it into the Date constructor:

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

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

The parts are:

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
Community
  • 1
  • 1
SimonGates
  • 5,961
  • 4
  • 40
  • 52