Curriculum 'User Guide Viedoc 4'

Difference between two time variables Download PDF

1 How to calculate the difference between two time variables?

  • If you want to calculate the difference in time between two time variables you can use the below code:

    if (!START || !END) return null;

    var diff = (END - START) / (1000 * 60); // minutes

    return diff;


    or

    if (!START || !END) return null;

    var diffInMinutes = ( END.getHours()*60+END.getMinutes() ) - ( START.getHours()*60+START.getMinutes() )

    return diffInMinutes;


    For more details about functions and how to use JavaScript in Viedoc see Using JavaScript in Viedoc .
  • As it is not possible to have time without a date in JavaScript the date is set automatically to current site date when the time is selected.

Was this information helpful?