Issue With Time Picker

I have created two-timepicker input box #timepicker1 and #timepicker2
and output box #c for its result my problem is I need to display total time in the output box #c
#timepicker1 user will enter the start time and
#timepicker2 user will enter the end time so
in the #c, I need to display the total time used,
by comparing the start time and end time

export function timePicker2_change ( event ) {
var starttime = parseFloat ( $w ( ‘#timePicker1’ ). value )
var endtime = parseFloat ( $w ( ‘#timePicker2’ ). value )
var total = endtime - starttime
$w ( ‘#c’ ). value = 'Total Time ’ + total + ‘hr’
}

from this code, it’s just minus the value
Help me to improve this code so that I can compare hours and minutes

I guess the “issue” is the last line, where you are trying to put a numeric value into a text-element, which expects a string. Use .toString() or .toFixed() or .toPrecision().