DateTime Formatting

2 posts, 0 answers
  1. Ashleigh L
    Ashleigh L avatar
    113 posts
    Member since:
    Jun 2012

    Posted 13 May 2015 Link to this post

    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",
            "Name":"Module 1",
                "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.

  2. Plamen
    Plamen avatar
    3080 posts

    Posted 14 May 2015 Link to this post


    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.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top