Re: Question about date calculations

From: Date: Fri, 30 Dec 2011 17:41:54 +0000
Subject: Re: Question about date calculations
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-316136@lists.php.net to get a copy of this message
On 12/29/2011 01:22 PM, Eric Lommatsch wrote:
Hello List, I am using PHP version 5.2.6.
I am using PHP V5.3.3 In my setup, the following lines give me errors stating that PHP cannot convert the DateTime object to a string. I was able to get around the error by changing your code to the following.
$intDayCnt=$dteEndDate[$i]-$dteStartDate[$i];
$intDayCnt = ( $dteEndDate[$i]->format('m') -
               $dteStartDate[$i]->format('m') );
Be sure to change the following line as well. $dteCheckDate = date('U');
if (($dteCheckDate>=($dteEndDate[$i]-7)&& $dteCheckDate<=($dteEndDate[$i]+1))&& $intDayCnt<16)
if (
     $dteCheckDate >= ( $dteEndDate[$i]->format('U') - (7*86400) )
     &&
     $dteCheckDate <= ( $dteEndDate[$i]->format('U') + (86400) )
     &&
     $intDayCnt < 16
) {
Eric Lommatsch.
-- Jim Lucas

« previous php.general (#316136) next »