Re: Date calculations
| From: | Edward van Bilderbeek - Bean IT | Date: | Thu, 21 Feb 2002 16:08:57 +0000 |
| Subject: | Re: Date calculations | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-85736@lists.php.net to get a copy of this message | ||
<?
$date1 = "2002-02-25 10:02:04";
$date2 = "2002-02-24 09:02:04";
list($date1,) = explode(" ", $date1);
list($date2,) = explode(" ", $date2);
list($year1, $month1, $day1) = explode("-", $date1);
list($year2, $month2, $day2) = explode("-", $date2);
$intdate1 = mktime('0', '0', '0', $month1, $day1, $year1);
$intdate2 = mktime('0', '0', '0', $month2, $day2, $year2);
$diff = abs($intdate1-$intdate2);
// $diff is number of seconds difference
// 1 day contains 60*60*24 seconds
print $diff / (60*60*24);
?>
Greets,
Edward
----- Original Message -----
From: "Sven Jacobs" <sjacobs@contenteurope.com>
To: <php-general@lists.php.net>
Sent: Thursday, February 21, 2002 4:56 PM
Subject: [PHP] Date calculations
> Hey
>
> I need to calculate the amount of days between 2 point
> point 1 is now the second point is in the past
> the format I have is in 2002-02-25 10:02:23 ( that is the format i have in
> my db )
> now if I have today 2002-02-25 10:02:04 and the other day is 2002-02-24
> 09:02:04
> That means that the delta in days is 1 day ( the hours do not mather )
>
> Somebody an idea ?????
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>