简体   繁体   中英

How to work out difference between H:i times on a 24 hour clock?

I am creating something that calculates fees based on the duration of a nightly event. Sometimes these events go over into the early hours of the following morning.

I have a table in my database that looks similar to this (just so you can see how the dates are formatted):

Start Time        Finish Time
23:30             00:00
21:00             01:30
20:00             22:00

There is no date or timestamp attached to any of these times. It is assumed that if the Finish Time is "earlier" on a 24 hour clock then it must be the day after.

I am lost.

如果结束时间小于开始时间,则将24:00添加到结束时间并进行计算。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM