I am creating a sort of ticketing system where cases are created and have a set time period to be answered in.
The start-time is stored in the database as a timestamp e.g. 2013-10-16 01:39:00, datetime field in mysql. There is also a resolve-by timestamp stored which could be set to 8 hours after the start-time.
When a case is either marked as resolved or put on hold a stop-time timestamp is stored in the database as well as a clock_stopped flag. This means that the 8 hour time countdown is stopped. When a case is no longer on hold or is re-opened then the time countdown is restarted. But its not to include the period of time which the clock was stopped. So the total time to resolve case remains 8 hours even if it was on hold for a day. Make sense?
What is the best way to work out elapsed time when including periods of time when the elapsed time is not counting down as above? Do I need to add in more fields to store in the database e.g. How would you do it?