formula for tracking minutes/hours occurring during business

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
churd
Forum Newbie
Posts: 8
Joined: Tue Feb 09, 2010 7:44 pm

formula for tracking minutes/hours occurring during business

Post by churd »

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 :) .
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: formula for tracking minutes/hours occurring during busi

Post by AbraCadaver »

Something like this should get you started. You just need to build an array of holiday dates and check that the same as checking the working days:
viewtopic.php?f=1&t=116365
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
churd
Forum Newbie
Posts: 8
Joined: Tue Feb 09, 2010 7:44 pm

Re: formula for tracking minutes/hours occurring during busi

Post by churd »

AbraCadaver wrote:Something like this should get you started. You just need to build an array of holiday dates and check that the same as checking the working days:
viewtopic.php?f=1&t=116365
Thanks!!
Post Reply