Time to now using Kendo UI

2 posts, 0 answers
  1. Purna
    Purna avatar
    17 posts
    Member since:
    May 2012

    Posted 19 Jan 2016 Link to this post

    I want to be able to convert Date into a "Time from now" format. I can accomplish the same using Moment.js library, but if I achieve the same using Kendo UI, I see no point in using Moment.js  


    What's the simplest way to get this done using Kendo. I don't want to get into manually parsing date object, and then diffing the date from now etc.. 

  2. Konstantin Dikov
    Konstantin Dikov avatar
    2126 posts

    Posted 20 Jan 2016 Link to this post

    Hi Purna,

    In Kendo UI there is no method that will calculate the difference between two dates and you will have to use either a custom library or the following simple JavaScript that will calculate the days between two dates:
    var today = new Date());
    var selected = $("#datePicker").data("kendoDatePicker").value();
    var diff = Math.round((selected - today)/1000/60/60/24); //Difference in days

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