Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KendoUI formatting date and time field

I am trying to turn a previously date only field to a date-time field but it is not working.

I have:

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

But this doesn't work, the date comes out formatted properly but the time ends up being 00:00.

If I change the field type to "string" the data shows properly but is formatted the SQL way i.e:

2012-05-11 12:56:29

There is no such field type as "datetime", only "date". How do I get this to output how I want? i.e:

11/05/2012 12:56

Any one have any ideas?

like image 741
imperium2335 Avatar asked Feb 18 '13 08:02

imperium2335


People also ask

How do I change the date format in kendo?

Renders a general date/time pattern (long time) ( "M/d/yyyy h:mm:ss tt" for en-US). For example, kendo. toString(new Date(2000, 10, 6), "G") -> 11/6/2000 12:00:00 AM . Render a month/day pattern ( "MMMM dd" for en-US).

How do you format a date?

Press CTRL+1. In the Format Cells box, click the Number tab. In the Category list, click Date, and then choose a date format you want in Type.

What is Kendo culture?

Kendo is a martial art that is based on Japanese swordsmanship techniques. Practitioners use bamboo swords and wear protective armor.


2 Answers

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

like image 177
napoleonss Avatar answered Sep 29 '22 12:09

napoleonss


Where are you trying to use this data? If you're using 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 the formatting in a grid

like image 27
VtoCorleone Avatar answered Sep 29 '22 13:09

VtoCorleone