Calculate working days between dates

Reply

Join Date: Dec 2007
Posts: 6
Reputation: gooky9 is an unknown quantity at this point 
Solved Threads: 0
gooky9 gooky9 is offline Offline
Newbie Poster

Calculate working days between dates

 
0
  #1
Dec 4th, 2007
Hi,

I need to calculate the number of working days between 2 dates entered in a page using PHP. The dates and the calculated number then need to be put into a MySQL database.

I am new to PHP, but understand the linking to the database and basic fnctions within PHP. Unfortunately I'm struggling with the calculation of the working days between dates.

Any help will be appreciated!
Thank You!

Steve
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Calculate working days between dates

 
0
  #2
Dec 4th, 2007
  1. <?php
  2. $date1="2007-11-04"; //date 1 smaller than the 2nd date
  3. $date2="2007-12-06";
  4. $difference= (strtotime($date2) - strtotime($date1))/(24*60*60);
  5. print $difference;
  6. ?>

Hope it helps.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 9
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

Re: Calculate working days between dates

 
0
  #3
Dec 6th, 2007
so i guess you need to calculate days (mon-friday)
and to exclude sat & sun
is that it?
programming is an art ,only for those who can understand it.
- th3 php wr3nch -
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 6
Reputation: gooky9 is an unknown quantity at this point 
Solved Threads: 0
gooky9 gooky9 is offline Offline
Newbie Poster

Re: Calculate working days between dates

 
0
  #4
Dec 11th, 2007
Yes! The code above calculates the days between the dates but i only need to count between Monday and Friday!!! Any help will be great, thanks!!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC