Ehtesam
Ehtesam

Reputation: 31

Kendo Grid Date Column Does not show real date

My kendo grid is showing date like this /Date(691869600000)/ . How do i solve this?

Upvotes: 2

Views: 7660

Answers (5)

Nightflame
Nightflame

Reputation: 21

var offsetMiliseconds = new Date().getTimezoneOffset() * 60000;

    #= kendo.toString(new Date( parseInt(JSONDateTime.substr(6)) + offsetMiliseconds),"dd-MMM-yyyy hh:mm tt") #

Upvotes: 0

maiconmm
maiconmm

Reputation: 311

Using this answer I got the Steve code to work for my case. Try this template:

"#= kendo.toString(new Date(parseInt(myField.substr(6))),'MM/dd/yyyy HH:mm tt')#"

Upvotes: 7

steve
steve

Reputation: 664

'#= kendo.toString(yourDateField,"MM/dd/yyyy HH:MM tt")#'

and make your field type as date.

Upvotes: 2

Carl
Carl

Reputation: 1258

You need to specify the date as a type in your datasource definition - else it will just be a string:

For example if your field is birthday:

var kendoDS = new kendo.data.DataSource({
schema: { 
 model: {
 fields: {
  birthday: { type: "date"}
 }
 }           
});

And when you define the Grid:

kendoGrid({
 selectable: whatever values..etc
 columns: your-response,
 dataSource: kendoDS 
});

See this for more info: http://www.kendoui.com/forums/framework/data-source/json-date-handling-changed-in-latest-release.aspx

Upvotes: 1

Petur Subev
Petur Subev

Reputation: 20223

Use template like the following or like the one in the documentation link.

#= kendo.format("{0:d}",theDateTimeFieldName)#

Upvotes: 0

Related Questions