How can I calculate the time between two clock times that cross midnight?
I don’t want to use a date picker as the date is irrelevant. The user should only input the start and end time, for example 10:00 PM - 08:00 AM. I want to calculate how many hours this is, which would be 10 hours. Subtracting the end time from the start time won’t work in this scenario.
This depends on how you are providing the user with the choices…if it is from a dropdown that uses an option set you create with hours of the day, then simply add an attribute to the option values to be ‘total number of minutes’ and subtract the two and if the end is less than the start do a *-1
But, sounds like you intend to use a date-time picker, which will also be choosing a date, so simply take the end date/time minus the start date time and use operator :format as number of hours