Re: Calculating dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks.  That's a nifty way of doing this.  Ron

On Fri, 2008-02-29 at 22:08 -0800, Jim Lucas wrote:
> Ron Piggott wrote:
> > Is there an easy way to calculate the number of days between two dates?
> > 
> > Example: 2008-02-27 - 2007-12-03 = 86 days
> > 
> > The dates will be in the format above YYYY-MM-DD
> > 
> > Ron
> > 
> 
> This should do the trick
> 
> <?php
> 
> $date1 = '2008-02-27';
> $date2 = '2007-12-03';
> 
> $udate1 = strtotime($date1);
> $udate2 = strtotime($date2);
> 
> $factor = 86400;
> 
> 
> $difference = (($udate1 - $udate2) / $factor);
> 
> echo "The difference is {$difference} days";
> 
> 
> Jim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux