Datetime format in column of Grid
1 Answer 1073 Views
Bertha
Top achievements
Rank 1
Bertha asked on 21 Jul 2014, 02:16 PM
I am using api with json to get the date.  With the attached code, I can get the date in correct format in Grid column but the time is always 12:00.  How can I fix that.

            { field: "RequestedDate", title: "Requested Date", width: "150px", type:"datetime", template: "#= kendo.toString(kendo.parseDate(RequestedDate, 'yyyy-MM-dd'), 'dd MMM yyyy hh:mm') #" },


Thanks.
Hi Bertha,

What is the raw value of RequestedDate? It might be possible that the format is not recognized by kendo.parseDate.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
- by
Alexander Valchev
Telerik team
on 22 Jul 2014, 03:28 PM
The format is from web api.  so, it is "2014-07-22T14:58:27.683".
How can I make it work?  Thanks.
- by
Bertha
Top achievements
Rank 1
on 23 Jul 2014, 02:08 PM

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 25 Jul 2014, 08:50 AM
Hi Bertha,

Thank you for the additional information.

In order to fix the issue please change the template to:
template: "#= kendo.toString(kendo.parseDate(RequestedDate), 'dd MMM yyyy hh:mm') #"

On a side note, the RequestedDate should be already parsed as date. It seems that in your case it is not, please check if the field is set to type: "date" in the dataSource.schema.model.fields configuration.
Once it is set to type date the dataSource automatically parse and the template will be simplified to:
template: "#= kendo.toString(RequestedDate, 'dd MMM yyyy hh:mm') #"

I hope this information will help.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Thanks.

I mark it as datetime.  After I changed it to date, the time shows properly.

   RequestedDate: { nullable: false, type: "datetime" },
- by
Bertha
Top achievements
Rank 1
on 25 Jul 2014, 01:37 PM

Hi

 

what is the default format recognized from the kendo datetime parser for columns of type date ? in many examples I see 2014-07-22T14:58:27 ?

 

More simply, I need to change server response format to adhere at a recognized format, where is documented the right format so I can only specify schema.model.field.type == date without needing more code ?

 

 

- by
Paolo
Top achievements
Rank 1
on 17 May 2017, 11:07 AM
Hi Paolo,

The date format depends on the current culture. More information on this matter could be found in the following help article:

Best Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
- by
Konstantin Dikov
Telerik team
on 19 May 2017, 07:38 AM
Thanks Konstantin, I will try
- by
Paolo
Top achievements
Rank 1
on 30 Oct 2017, 10:43 AM
Tags
Grid
Asked by
Bertha
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or