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

<?php
$date1="2007-11-04";  //date 1 smaller than the 2nd date
$date2="2007-12-06";
$difference= (strtotime($date2) - strtotime($date1))/(24*60*60);
print $difference;
?>

Hope it helps.

so i guess you need to calculate days (mon-friday)
and to exclude sat & sun
is that it?

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!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.