# Decimal Time Calculation

Home Forums Quform WordPress Decimal Time Calculation

This topic is: not resolved
Viewing 6 posts - 1 through 6 (of 6 total)
• Author
Posts
• #24741

Hello,
im from Germany and my english is no good, but i hope we can solve the problem here.

In our form we have time selection. 1 start time and 1 end time – these for 7 days (1start and 1end per day). I want to calculate the start and the end in decimal and have 1 field per day that shows me the calculated day in decimal. Then i want calculate the 7 days to a one week field in decimal.

Example:

Day 1: Start at 10:00 – End at 12:45 = 2,75 hours for day 1 in decimal
Day 2: Start at 10:00 – End at 13:00 = 3 hours for day 2 in decimal
Day 3: Start at 10:00 – End at 12:15 = 2,25 hours for day 3 in decimal
Day 4: Start at 10:00 – End at 12:17 = 2,28 hours for day 4 in decimal
Day 5: Start at 10:00 – End at 12:20 = 2,33 hours for day 5 in decimal
Day 6: Start at 10:00 – End at 12:45 = 2,75 hours for day 6 in decimal
Day 7: Start at 10:00 – End at 12:45 = 2,75 hours for day 7 in decimal

Week hours in decimal: 18,11

our form: spesen.kraftfahrer-gmbh.com

I have attached a foto with a example from our form.
_
Best Regards
lesz333

###### Attachments:
You must be logged in to view attached files.
#24780

#31563

Hi,

The user will select start time (1_6) and end Time (1_7), upon selection I want a field (1_50) to display total hours requested just like above but I want to add 12 hours if PM

jQuery(function (\$) {
function convertTimeToMinutes(time) {
var parts = time.split(‘:’);
//if PM add 12 hours ???
return (60 * parseInt(parts, 10)) + parseInt(parts, 10);
}
// Number of hours requested
\$(‘.quform-field-10_6, .quform-field-10_7’).on(‘change blur’, function () {
var start = \$(‘.quform-field-1_6’).val(),
end = \$(‘.quform-field-1_7’).val(),
total = 0;

if (start && end) {
start = convertTimeToMinutes(start);
end = convertTimeToMinutes(end);

total = (end – start) / 60;
}

\$(‘.quform-field-1_50).val(total);

});
});

#31564

#31580

Hi Ally,

Thanks, it worked.