Andrus
Andrus

Reputation: 27943

How to show date in normal format in jqgrid when formatter is used

Date column is created using colmodel below. This column shows values like 0101.0101.7070 for every date column. if formatter:date is removed, date is correct.

How to show normal date values with formatter:date ?

{ "name":"Date",
"formatter":"date",
"datefmt":"dd.mm.yyyy",
"formatoptions":{"newformat":"dd.mm.yyyy"},
"editable":true
}

Update.

Data is passed from server using json in same dd.mm.yyyy format like

{"total":2,"page":1,"records":57,"rows":
[{"id":"9279","cell":["9279","42","","10.08.2011","","","","False"]},
 {"id":"9278","cell":["9278","41","","12.08.2011","","","","False"]},

...

Using d.m.y formats in column options as suggested shows proper dates but with 2 year digits only.. I'm looking for a 4-digit year numbers. I tried d.m.yyyy format but this shows 8 digit year numbers and 1 for month and day as 01.01.70707070

I also tried to add srcformat: 'dd.mm.yyyy' to formatoptions but this does not change the wrong result.

Upvotes: 2

Views: 7031

Answers (2)

Oleg
Oleg

Reputation: 221997

To display the day as the number you should use j or d. For the displaying month as the number you should use n or m. The d and m includes 0 padding at the beginning if needed. The 'y' means two digit year format and Y means four digit year.

So you probably need srcformat: 'd.m.Y' or srcformat: 'j.n.Y'.

Upvotes: 3

an0nym0usc0ward
an0nym0usc0ward

Reputation: 1227

Use d.m.y instead of dd.mm.yy ,

Upvotes: 0

Related Questions