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

DateTime Formatting

1 Answer 13 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Ashleigh L
Top achievements
Rank 1
Ashleigh L asked on 13 May 2015, 06:00 PM

I'm trying to use a single datetime field in my datasource to display the date and time pieces separately, but the formatting isn't working for some reason. 

Here's piece of example JSON:

{"Course": {
    "Name":"Test Course",
    "ChapterData":[{
        "Name":"Module 1",
        "TaskData":[{
            "Name":"Module 1 Task 1",
            "CompletedDate":"05\/12\/2015 19:25:43"
        }]
    }]
}}
And this is the template where I'm trying to format the values:

<i class="fa-icon-check mar-rt-sm"></i>#= kendo.toString(data.ChapterData[c].TaskData[t].CompletedDate, 'dd-MMM-yyyy') #
<span class="hidden-xs">#= kendo.toString(data.ChapterData[c].TaskData[t].CompletedDate, 'h:mm tt') #</span>

As you can see, I'm trying to display the date as "12-May-2015" and the time as "7:25 PM", but I just keep getting the whole, unformatted string ("05/12/2015 19:25:43") on my display. I wasn't able to find any information on time formatting specifically, and even when I created separate nodes in the JSON (ie. CompletedDate and CompletedTime), I still couldn't get the formatting to work.

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 14 May 2015, 06:18 AM
Hi,

You are actually passing sting so you will have to turn it to Data before you as it is explained in this help topic and then use the toString() method. Here is the code that worked at my side.

Regards,
Plamen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
Ashleigh L
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or