Re: Finding num of days b/t two dates.
| From: | Steve Cayford | Date: | Fri, 07 Dec 2001 23:53:47 +0000 |
| Subject: | Re: Finding num of days b/t two dates. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-77090@lists.php.net to get a copy of this message | ||
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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net