Re: Date math

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

 



At 12:17 AM -0400 3/24/08, Ron Piggott wrote:

I have this math equation this list helped me generate a few weeks ago.
The purpose is to calculate how many days have passed between 2 dates. Right now my output ($difference) is 93.9583333333 days.
I am finding this a little weird.  Does anyone see anything wrong with
the way this is calculated:

$date1 = strtotime($date1); (March 21st 2008)
$date2 = strtotime($date2); (December 18th 2007)

echo $date1 => 1206072000
echo $date2 => 1197954000

#86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days
worth of seconds)

$factor = 86400;

$difference = (($date1 - $date2) / $factor);

94 - 93.9583333333 = .0416666666667

.0416666666667 * 86400 = 3600 = 1 hour. Didn't you pass throught daylight savings time prior to 21 March?

     -----===== Bill =====-----
--

You can't tell which way the train went by looking at the track.

--
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