Home › Forums › Quform WordPress › Decimal Time Calculation
- This topic has 5 replies, 2 voices, and was last updated 4 years, 5 months ago by Ally.
- AuthorPosts
- March 19, 2018 at 11:57 am #24741lesz333Participant
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 decimalWeek hours in decimal: 18,11
our form: spesen.kraftfahrer-gmbh.com
I have attached a foto with a example from our form.
_
Best Regards
lesz333Attachments:
You must be logged in to view attached files.March 23, 2018 at 1:40 pm #24780AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 20, 2020 at 6:02 pm #31563naser87ParticipantHi,
I am trying to do something similar to this, please help me with the code.
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[0], 10)) + parseInt(parts[1], 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);
});
});June 22, 2020 at 10:21 am #31564AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 26, 2020 at 7:30 pm #31580naser87ParticipantHi Ally,
Thanks, it worked.
Could you please help me add a logic that prevents endTime form being before startTime; endTime values start after the startTime value.
Thanks in advance
July 1, 2020 at 10:00 am #31591AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.