Count days within a month from date range

QuestionsCategory: PHPCount days within a month from date range
Keerthi asked 3 weeks ago
  • from 2013-09-29 to 2013-10-02
  • from 2013-10-14 to 2013-10-16

I want to count only days that occur in Month of October, for example from first range (2013-09-29 to 2013-10-02) I should get difference of two days (1st and 2nd October) , and it should ignore days from September month, Finally i want to count total days in a given month from above date ranges.
Can it be done from mysql query and PHP or any other scripting languages.
Actually I want to count number of leaves of an employee within a month between two dates.  For this I wrote code like this below. 
 
while($row = mysqli_fetch_array($result)) {

$empid = $row[’empid’];
$end = strtotime[‘end’];
$start=strtotime[‘start’];
$days= abs($end – $start);
$numberDays = $days/86400;
$numberDays = intval($numberDays + 1 );
echo “<tr><td>”.$row[‘days’].”</td>
<td>”.$empid.”</td><td>”.$numberDays.”</td></tr>”;

}
Please help me how to get count of number of leaves of an employee with in a month between two dates.
Thank you.