User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,772 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2251 | Replies: 3
Reply
Join Date: Dec 2007
Posts: 6
Reputation: gooky9 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gooky9 gooky9 is offline Offline
Newbie Poster

Help Calculate working days between dates

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Calculate working days between dates

  #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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Dec 2006
Location: syria
Posts: 158
Reputation: w_3rabi is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 8
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

Re: Calculate working days between dates

  #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  
Join Date: Dec 2007
Posts: 6
Reputation: gooky9 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gooky9 gooky9 is offline Offline
Newbie Poster

Re: Calculate working days between dates

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:23 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC