Reputation: 24132
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?
Upvotes: 8
Views: 33252
Reputation: 1139
You must use a template '#= kendo.toString(kendo.parseDate(dateCreated), 'MM/dd/yyyy HH:mm tt')#'
Upvotes: 24
Reputation: 17203
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
Upvotes: 8