Time difference between two time data types

Hi All,

How to make a time difference between two time data types in 24 hours time format

frappe.ui.form.on(‘Compensatory Approval Form’, {
refresh: function(frm) {

},
out_time: function(frm) {
	console.log("in time and out time",frm.doc.in_time,frm.doc.out_time);
	total = frm.doc.out_time - frm.doc.in_time;
	console.log("Total time ",typeof(total));
	var start = moment(frm.doc.in_time, "HH:mm");
	console.log(start._i);
var end = moment(frm.doc.out_time, "HH:mm");
var minutes = end.diff(start, 'minutes');
	console.log(minutes);
var hours = Math.trunc(minutes/60);
	var m1 = minutes%60;
	var total_t = hours + ":" + m1;
	console.log(total_t);
	total_time = total_t;
	console.log(typeof(total_time));
	refresh_field('total_time');
}

});

but the value between these two fields not updating to the total field will any one help me this

1 Like

Try this

frm.set_value('total_time', total_time)
1 Like