php - addtime with more than two and mixed argument -
i making work time tracking database needs calculating on work hours well.
the simple operation possible through.
addtime(`starttime`,-`endtime`)
but need calculations on more numbers fail.
say work can span on midnight , starttime: 20:00:00 , endtime 06:00:00 like:
if(`starttime`<`endtime`, addtime(`endtime`,-`starttime`),addtime(`endtime`, addtime (-`starttime`,24:00:00))) tid 1
but isn´t accepted.
and when need add in possibility lunch break gets more complicated.
what do?
to keep calculations simple, i'd suggest along start , end times, store start , end dates, in same field. doing so, can find working hours doing below in mysql query:
timestampdiff(hour, `start_datetime`, `end_datetime`);
Comments
Post a Comment