Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo grid format time issue in date column [duplicate]

I have a kendo grid, it has a date column. I want to show date and time there. I am using below format in column definition,

format: "{0:dd-MMM-yyyy hh:mm:ss tt}"

In modal I used date type Updated_Date: { type: "date" }

Output date is coming as '10-Oct-2013 12:00:00 AM', but actual date returned via ajax call is "Updated_Date":"2013-10-10T05:02:40.44"

What to do to show the correct time in Grid like 10-Oct-2013 05:02:40 AM?

like image 522
Jom Avatar asked Dec 16 '22 05:12

Jom


1 Answers

There are two fields that are commonly confused:

  • format : Specifies the format, which is used to format the value of the DateTimePicker displayed in the input.
  • parseFormats: Specifies the formats, which are used to parse the value set with value() method or by direct input.

So actually you need to define a parseFormat because of the T between date and time that makes the format not being a default one:

Try:

columns   : [
    ...
    {
        field       : "Date",
        title       : "Date",
        format      : "{0:dd-MMM-yyyy hh:mm:ss tt}",
        parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]
    }
]

Running example here : http://jsfiddle.net/OnaBai/Ahq6s/

like image 125
OnaBai Avatar answered Jan 06 '23 04:01

OnaBai