Jqgrid display date 01/01/0001

184 Views Asked by At

I am using jqGrid to bind data and i have a date field which i am binding it to grid. The date is 01/01/0001, but when i try to bind it to grid, it is displaying as 1/1/1. How can i display with out truncating zeros.

I am using "Guriddo jqGrid JS - v5.2.1"

below is my sample colModel for the date i have implemented

{
    name: "orderDate", 
    label: "orderDate", 
    align: "left", 
    jsonmap: "orderDate", 
    formatter: "date", 
    formatoptions: { newformat: 'm/d/Y' }
}
1

There are 1 best solutions below

0
Tony Tomov On

First of all you will need to set the source format (srcformat). The default srcformat is Y-m-d

In you case you will need to set:

{
    name: "orderDate", 
    label: "orderDate", 
    align: "left", 
    jsonmap: "orderDate", 
    formatter: "date", 
    formatoptions: { srcformat : m/d/Y, newformat: 'm/d/Y' }
}

Second which is more important is that dates in Javascript begin since 1 jan 1970. Your source date is not correct and it will be not interpreted correcy

In your case you will need to define your own (custom) formatter to do what you want.