I decided to enhance the DateTime object by taking advantage of method chaining.
<?php
class DateTimeChain extends DateTime {
public function modify ($modify) {
parent::modify($modify);
return $this;
}
public function setDate ($year, $month, $day) {
parent::setDate($year, $month, $day);
return $this;
}
public function setISODate ($year, $week, $day = null) {
parent:: setISODate($year, $week, $day);
return $this;
}
public function setTime ($hour, $minute, $second = null) {
parent::setTime($hour, $minute, $second);
return $this;
}
public function setTimezone ($timezone) {
parent::setTimezone($timezone);
return $this;
}
}
$t = new DateTimeZone('America/Los_Angeles');
$d = new DateTimeChain();
var_dump($d->setTimezone($t)->modify('5years')->format(DATE_RFC822));
?>