in reply to calculate hours of day

Two problems that might arise (and two reasons you might consider following Zaxo's advice):

1) What happens if your $fromTime is say 2359 and your $toTime is 0009? It would be fairly easy to adjust eg CombatSquirrel's solution for this, but only if you can be sure that the $toTime is on the following day, ie that the elapsed time is 10 minutes, and not 24 (or 48, or 72...) hours and 10 minutes.

2) Twice a year, if you live in a country that has daylight saving time, you will have wrong results in the early hours of the morning :-)

dave