note 98127 deleted from class.datetime by danbrown

From: Date: Tue, 01 Jun 2010 15:02:18 +0000
Subject: note 98127 deleted from class.datetime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169802@lists.php.net to get a copy of this message
Note Submitter: Vanylla.com ---- The add methos is confusing and too long to be used cause you have to create a DateInterval object. We extended the DateTime class by adding methods that are frequently used in our applications' code: <?php addDays($number_of_days) addMonths($number_of_months) //etc. ?> don't know if PHP will ever add those, in the meantime you could do: <?php class MyDateTime extends DateTime { public function addDays($number_of_days) { //below use 'D' for days, 'Y' for years, 'M' for months, $this->add(new DateInterval('P' . $number_of_days . 'D')); } //public function addMonths... //public function addYears... } ?>

« previous php.notes (#169802) next »