enter time-1 // eg 01:12
enter time-2 // eg 18:59
calculate: time-1 to time-2 / 12
// i.e time between 01:12 to 18:59 divided by 12
How can it be don
Assuming that the user is entering strings like "01:12"
, you need to convert (as well as validate) those strings into the number of minutes since 00:00
(e.g., "01:12"
is 1*60+12
, or 72 minutes), then subtract one from the other. You can then convert the difference in minutes back into a string of the form hh:mm
.