如何计算PHP和MYSQL中两个日期之间的天数

I need to calculate number of days between two dates. Required date entered by me,fetch the record from the database by the given dates. If the database have 'startdate' as 1Jan2015 'enddate' as 5Feb2015. For January month it should return 30 and for February 5 days.

My table:

id  Name    Type    Project Place            Start Date              End Date                Details
1   Sai Local   Site    Bangalore   2015-09-03 11:32:47 2015-09-05 11:32:47 test                    
2   Ram Local   IGCAR   Chennai     2015-04-01 15:15:36 2015-04-09 15:15:36 Installation                    
3   Mani    Local   IGCAR   Chennai     2015-04-16 15:16:18 2015-05-21 15:16:18 Training

My coding

///////////Employee Outstation(Travel) details/////////////
    $employeeTravel = new EmployeeTravelRecord();
    //date_start = '2015-04-01' ;
    //date_end   = '2015-04-30';

    $TravelEntryList = $employeeTravel->Find("(travel_date between ? and ? or  return_date between ? and ? )",array($req['date_start'], $req['date_end'],$req['date_start'], $req['date_end']));
    foreach($TravelEntryList as $Travelentry){

    $amount = (strtotime($Travelentry->return_date) - strtotime($Travelentry->travel_date));

                }   

For second record, it returns correct value, but for third record it calculates including May month. But i want only 30 days of april.

DATEDIFF() returns value in days from one date to the other.

select *,datediff( end Date,  Start Date) as days from My table;

Please have a look at this post, you should find what you're looking for :

How to get the number of days of difference between two dates on mysql?

There is a function in PHP called as date_diff for difference between two dates.

<?php
$date1 = date_create("2013-03-15");
$date2 = date_create("2013-12-12");
$diff = date_diff($date1,$date2);
echo $diff->format("%R%a days");

?>