KendoUI Format Date and Time Field

I am trying to turn a date field only into a date field, but it does not work.

I have:

schema: { model: { id: 'id', fields: { dateCreated: { type: "date", format: "{0:yyyy/MM/dd HH:mm}", editable: "false" }, ... } } 

But this does not work, the date is displayed correctly, but the time ends 00:00.

If I changed the type of the field to "string", the data will be displayed correctly, but the format of SQL ie is formatted:

 2012-05-11 12:56:29 

There is no such type of field as "date-time", only "date". How can I get this for output as I want? i.e:

 11/05/2012 12:56 

Does anyone have any idea?

+8
jquery kendo-ui kendo-grid
source share
2 answers

You should use the template '#= kendo.toString(kendo.parseDate(dateCreated), 'MM/dd/yyyy HH:mm tt')#'

+18
source share

Where are you trying to use this data? If you use it in a grid, you can use the "template" property in the column definition

 var columnDefinition = [ { field: "dateCreated", title: "Created", template: "#= kendo.toString(dateCreated,'MM/dd/yyyy HH:mm tt') #" } ]; 

Here's a fiddle with formatting in a grid

+8
source share

All Articles