| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
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...
}
?>
----
Server IP: 81.88.49.23
Probable Submitter: 151.16.87.188
----
Manual Page -- http://www.php.net/manual/en/class.datetime.php
Edit -- https://master.php.net/note/edit/98127
Del: integrated -- https://master.php.net/note/delete/98127/integrated
Del: useless -- https://master.php.net/note/delete/98127/useless
Del: bad code -- https://master.php.net/note/delete/98127/bad+code
Del: spam -- https://master.php.net/note/delete/98127/spam
Del: non-english -- https://master.php.net/note/delete/98127/non-english
Del: in docs -- https://master.php.net/note/delete/98127/in+docs
Del: other reasons-- https://master.php.net/note/delete/98127
Reject -- https://master.php.net/note/reject/98127
Search -- https://master.php.net/manage/user-notes.php