Monday, October 22, 2012

PHP Function to calculate days difference between given 2 dates.

Here is a simple  Function to calculate days difference between given 2 dates.



function daysDifference($endDate, $beginDate)
{

              //explode the date by "-" and storing to array
             $date_parts1=explode("-", $beginDate);
             $date_parts2=explode("-", $endDate);
             //gregoriantojd() Converts a Gregorian date to Julian Day Count
            $start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
             $end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
             return $end_date - $start_date;
}

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...