getting a string result from Date

From: Date: Thu, 01 Apr 2004 16:24:29 +0000
Subject: getting a string result from Date
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11570@lists.php.net to get a copy of this message
Am really enjoying PEAR's Date class, it seems capable of handling all date manipulation needs. However I have come across one hitch which I've solved but don't understand the solution. Does any understand why the first method of assigning the results of a date span operation to a string works and not the (commented) second? tia demian winXP apache 1.3.29 PHP 4.3.4 ======================== require_once 'Date.php'; $aPreviousWeeks = array(
    7  => '1 week before',
    14 => '2 weeks before',
    21 => '3 weeks before',
    28 => '4 weeks before',
    35 => '5 weeks before',
); $currDate = "2003-9-04"; foreach ($aPreviousWeeks as $k => $v) {
    $date = new Date($currDate);
    //  args are $days, $hours, $minutes, $seconds
    $date->subtractSpan(new Date_Span("7, 0, 0, 0"));
    $currDate = $date->format('%Y-%m-%d');
    #$currDate = "{$date->year}-{$date->month}-{$date->day}"
    var_dump($currDate);
}

« previous php.pear.general (#11570) next »