This is a migrated thread and some comments may be shown as answers.

Problem with json dates and globalization

2 Answers 160 Views
Globalization
This is a migrated thread and some comments may be shown as answers.
Jose
Top achievements
Rank 2
Jose asked on 30 May 2012, 11:57 AM
Hi,
I'm working with kendo listview and datasource.
Dates from Json data are returned as "\/Date(1338364370930)\/".
This is my current date part template:
<dt>@FieldNames.CreateDate :</dt>
<dd>#= (CreateDate == null) ? ' ' : kendo.toString(new Date(parseInt(CreateDate.substr(6))), "d") #</dd>

I've had to add the "new Date(parseInt(CreateDate.substr(6)))" part in order to show correctly the date.
Without this code the date appear \/Date(1338364370930)\/ without conversion. This is my first issue. Why kendo datasource or listview cannot process or convert directly json dates?

My second issue is I'm converting the date to a short format with "d", currently my culture is spanish and the date appears as "5/30/2012" (m/dd/yyyy). This is wrong, in spain it must be "30/5/2012" (dd/m/yyyy). I've checked my internet explorer and the language is set to spanish. Tried with Chrome and with the same result. Any idea? 

Regards
Jose

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 04 Jun 2012, 06:52 AM
Hello Jose,

 
Straight upto your questions:

#1: The toString method formats Date, Number objects to string. You can find more information about the method here. In the aforementioned case the passed value is a string ("\/Date(1338364370930)\/") and the toString method just returns it. That is why you need to parse it (like you do) and pass it to the method.

#2:
The KendoUI works with current set culture. By default it is "en-US". If you need to change it, you will need to register the corresponding JS culture file and set the current culture to it. Check this help topic for more information. You can also check this online demo.

I will suggest you open support tickets for your incedents. Thus our support team can handle the problems faster. We also do not guarantee answers in the forum threads.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jayson
Top achievements
Rank 1
answered on 03 Aug 2012, 01:35 PM
I have same problem, how can i accomplish this using GridBoundColumnBuilder? Here's my code:

var colBuilder = columns.Bound(propertyName).Title("Changed Date").Filterable(true);
colBuilder.Format("{0:dd/MMMM/yyyy}");

The output is always "/Date(1338364370930)/".                       
Tags
Globalization
Asked by
Jose
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Jayson
Top achievements
Rank 1
Share this question
or