Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML date and time manipulation



  • how we cam get distance between 2 dates ?



  • Welcome to the devnet forums,

    Please don't continue in the same old threads. I'll split this one as a separate thread.



  • @
    var then = new Date(2014, 10, 1);

    var now = new Date(); // The current date and time
    var elapsed = now - then; // Date subtraction: interval in milliseconds
    @

    Then you wil need to convert this result to hours and minutes



  • thanks
    i try something like this :
    @ function getDistance(time1) // time1 another date which i make by gettoday()
    {
    return Math.round((gettoday()-time1)/(606024));
    }

    function gettoday()
    {
        var nowdate = new Date();
        return nowdate/1000;
    }@

Log in to reply