formula for tracking minutes/hours occurring during business
Posted: Fri Jun 25, 2010 9:48 am
Hello all! I hope you don't mind helping out a relative PHP noob (working with it for 3 months now, and yes... it's my first programming language).
Here's what I need to do... I have a work-order system that is run off of a MySQL database, and I need to be able to track how long it takes for users to respond to requests. The catch is, if a request is initiated at 2 am in the morning, I don't want to track it... ONLY time that occurs during business hours.
My current idea is the following... I use CRON jobs on the server to refresh a .php page every minute that checks certain variables in my database and then responds accordingly... currently, I was going to have it do the following:
1) If the user has not responded yet, then look at the "Creation" timestamp (when the work order was submitted) and calculate how many minutes have passed. - NOTE: If hours = 4 with no response, then I penalize the contractor (I'm comfortable with this).
2) If the user has not responded yet, I will enter the number of minutes that have passed and the number of minutes left for the Contractor to respond.
3) The CRON job runs every minute, so it will be accurate +/- 59 seconds.
I'm comfortable with writing up the above coding... what I don't know how to do, is to write an "IF" statement that excludes all time/minutes that occur OUTSIDE of business hours. This should include national holidays.
I know the above might be confusing... if so, let me know where it is confusing and I'll clarify.
Any help is appreciated!!! Thanks in advance
.
Here's what I need to do... I have a work-order system that is run off of a MySQL database, and I need to be able to track how long it takes for users to respond to requests. The catch is, if a request is initiated at 2 am in the morning, I don't want to track it... ONLY time that occurs during business hours.
My current idea is the following... I use CRON jobs on the server to refresh a .php page every minute that checks certain variables in my database and then responds accordingly... currently, I was going to have it do the following:
1) If the user has not responded yet, then look at the "Creation" timestamp (when the work order was submitted) and calculate how many minutes have passed. - NOTE: If hours = 4 with no response, then I penalize the contractor (I'm comfortable with this).
2) If the user has not responded yet, I will enter the number of minutes that have passed and the number of minutes left for the Contractor to respond.
3) The CRON job runs every minute, so it will be accurate +/- 59 seconds.
I'm comfortable with writing up the above coding... what I don't know how to do, is to write an "IF" statement that excludes all time/minutes that occur OUTSIDE of business hours. This should include national holidays.
I know the above might be confusing... if so, let me know where it is confusing and I'll clarify.
Any help is appreciated!!! Thanks in advance