Calculate Time Duration

For a public form (not SharePoint form):

What's the best way to let users to enter start and finish times, then have a separate field which auto-calculates the duration?

1) What type of field is best for the Start & Finish time fields?
Dropdown with 15/30 minute increments?

Could we create a field where when users type in for instance '1132' the field auto-formats it to:'11:32'? Will this work if we try to work out the difference between the two times?

2) What code do we use in JS to workout the difference between start and finish time?

Thank you!
I tried a bunch of thing sand couldn't figure it out.

How do I do this:

I can use this elsewhere.

Dear @Viorel,
You could use different approaches here, depending on what you need - just time or dates as well? For dates, we recommend using Date & Time fields, they can be used with MomentJS to quickly calculate the difference - Work with Date and Time fields in public web forms using JS — Public web forms

If it's just time, perhaps Dropdown fields would be an option. It all depends on specific case + precision needed for the task. Are 15 minute intervals okay? Then dropdown can be good. If not, it's possible to transform text into time, and calculate difference, for example, using Masked input - Masked Input field — Public web forms

1 Like

The masked input field is exactly what I was looking for :ok_hand:

FYI, I play to ask for start for start and finish times using masked input field formatted like this : '00:00'

Then since I'm pulling the info into an excel file, I'll do the calculation in excel with the formula: '=FinishTime-StartTime'

I haven't tested it yet, but should work like a charm!

Massive thanks, Nikita!