note 77838 added to function.date-modify
| From: | someone at osu1 dot php dot net | Date: | Sat, 15 Sep 2007 06:46:58 +0000 |
| Subject: | note 77838 added to function.date-modify | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130506@lists.php.net to get a copy of this message | ||
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));
?>
----
Server IP: 69.147.83.197
Probable Submitter: 76.171.101.17
----
Manual Page -- http://www.php.net/manual/en/function.date-modify.php
Edit -- https://master.php.net/note/edit/77838
Del: integrated -- https://master.php.net/note/delete/77838/integrated
Del: useless -- https://master.php.net/note/delete/77838/useless
Del: bad code -- https://master.php.net/note/delete/77838/bad+code
Del: spam -- https://master.php.net/note/delete/77838/spam
Del: non-english -- https://master.php.net/note/delete/77838/non-english
Del: in docs -- https://master.php.net/note/delete/77838/in+docs
Del: other reasons-- https://master.php.net/note/delete/77838
Reject -- https://master.php.net/note/reject/77838
Search -- https://master.php.net/manage/user-notes.php