I'm currently writing the working hour calculation with Time In and Time Out to show working hour with decimal with 1 point. In my case i used .toFixed(1) and any other times are working well but when time in is 09:10 and time out is 17:30 .. It's result show as 8.333333333333334. .toFixed(1) not working in that decimal number. How should i do that.
Here is my code.
var time_in = $(elm).closest('tr').find('.time_in').text();
var time_out = $(elm).closest('tr').find('.time_out').text();
var working_time = (new Date("1970-1-1 " + time_out) - new Date("1970-1-1 " + time_in)) / 1000 / 60 / 60 ;
alert(working_time);
var total_work_hour = working_time.toFixed(1) - 1; //get fixed decimal number and minus 1 for lunch time.
var w_time = $(elm).closest('tr').find('.work_time');
w_time.text(total_work_hour);