Here's one way to do it by converting dates into timestamps.
<?php

$date1 = mktime(0,0,0,10,1,2001); // in the form (hours, minutes, 
seconds, month, day, year)
$date2 = mktime(0,0,0,10,1,2000);
$timedif = $date1 - $date2;

print(strftime("date 1 is %b %d, %Y", $date1) . "<br>\n");
print(strftime("date 2 is %b %d, %Y", $date2) . "<br>\n");
print("the difference in seconds is " . $timedif . "<br>\n");
print("the difference in days is " . ($timedif / (60 * 60  * 24)) . 
"<br>\n");
?>

-Steve

On Friday, December 7, 2001, at 04:48  PM, Alex Fritz wrote:

> If somebody could help me with this, it would save me a lot of 
> heartache.  I
> thought that this would be simple, but I can't seem to find a function
> anywhere in PHP that has this capability and I can't seem to find any
> external libraries for anything actually.  I need to be able to give 
> PHP a
> start date and an end date and have it return the number of days 
> between the
> dates.  If the first date is more recent than the second, I need it to 
> give
> me a negative number.  Can somebody please help?
>
> Alex
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to