Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detting number of days between 2 dates

Status
Not open for further replies.

smashing

Programmer
Oct 15, 2002
170
US
This is weird - Isn't every unix timestamp day exactly 86400 seconds apart?

I compare 2 date timestamps, remove the lesser from the larger, divide that number by 86400 (number of seconds in a single day) and that gives me the exact number of days betwenn the two. as in following code:
Code:
$retdbdate = ("$return_year-$return_month-$return_day");
//return date now in unixtimestamp
$retunixdate = strtotime($retdbdate);
$actual_retdbdate = ("$actual_return_year-$actual_return_month-$actual_return_day");
//actual return date now in unixtimestamp
$actual_retunixdate = strtotime($actual_retdbdate);
$days_late = ($actual_retunixdate - $retunixdate) /86400;

In most cases this comes out fine echoing the exact number of days in between. But when I had the later date as 2005-11-21 (timestamp = 1132549200 and the earlier date as 2005-09-21 (timestamp = 1127275200) the days in between come out as 61.04166666666666! Running the numbers thru a simple calculater I see the same results so where did I go wrong here
 
pass, what db are you using and isnt this the HardWay(tm) ?


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
The difference is exactly 3600 seconds, an hour, which makes me believe the daylight savings time change is taken into consideration. It happens sometime in October, the time span you are investigating.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top