A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Get Difference Between 2 Dates Using PHP

Here is how you get the number of days between two dates.

 
function getdays($day1,$day2)
{    
     return round((strtotime($day2)-strtotime($day1))/(24*60*60),0);
}
$begin = date("Y-m-d"); // we set today as an example
$end = "2007-01-29";
 
echo getdays($begin,$end).' days';

This was taken from the manual – posted by: michiel at mb-it dot nl

This entry was posted in General and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>