Re: date functions

From: Date: Sun, 19 May 2002 01:01:37 +0000
Subject: Re: date functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98308@lists.php.net to get a copy of this message
Well you could do two str2time() calls like this: # Two Dates to Compare # $date1 = strtotime("Oct 18, 2002"); $date2 = strtotime("Jan 18, 2002"); # Assign the earliest date and laterdate to variables # $earlyDate = ($date1 < $date2) ? $date1 : $date2; $laterDate = ($earlyDate == $date1) ? $date2 : $date1; # Computes to find how many days are between the two dates # $daysBetween = ceil(($laterDate - $earlyDate)/(60*60*24)); echo $daysBetween; There's probably an easier way of doing this, but hey it works! ;) Rick You will never be happy if you continue to search for what happiness consists of. You will never live if you are looking for the meaning of life. - Albert Camus > From: "Josh Edwards" <josho@tpg.com.au> > Date: Sun, 19 May 2002 10:22:28 +1000 > To: php-general@lists.php.net > Subject: [PHP] date functions > > Does anyone know a good way to count the days between two dates. ie how > many Mondays fall between two dates. As a starting point I have calculated > the start and end dates and the no of days b/w them. > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#98308) next »