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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difference between 2 dates

Status
Not open for further replies.

danmul

Programmer
Joined
Jan 16, 2003
Messages
89
Location
IE
does anybody have a function that returns the difference between 2 dates

please!!!!
 
I have figured this out.
cant c this code working for all senarios

function date_difference($date1, $date2)
{
$str1 = strtotime($date1);
$str2 = strtotime($date2);

$res = $str2 - $str1;

return $res/86400;
}
 
you by any chance using mysql as well ? or just good ole php?


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Hi,
I am using mysql also but these dates are taken from drop down lists so i do not access the database

Thanks for the reply
 
Perhaps the first FAQ in the FAQ list can help you out?
faq434-3493

Or your way is completely valid... assuming all you care about it is the number of days.... and assuming you're passing it $date1 and $date2 in ways you know will work with strtotime.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top