Count days between dates

Submitted by:Andery Smith

Date added:17 July, 2014

Category:PHP

Find how many days there are between two given dates.

Tags: count , count days

Code Snippet:

<?PHP

// First Date: 1 January 2005
// Second Date: 27 January 2005

$first_date = MKTIME(12,0,0,1,1,2005);
$second_date = MKTIME(12,0,0,1,27,2005);

$offset = $second_date-$first_date;

ECHO FLOOR($offset/60/60/24) . " days";

// This will display: 26 days.

?>
 
 

Comments