Re: Improve DateTime Class

From: Date: Mon, 10 Dec 2012 19:44:45 +0000
Subject: Re: Improve DateTime Class
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-64234@lists.php.net to get a copy of this message
On 10/12/12 13:35, Christian Stoller wrote: > Hm... I know '$date->add(new DateInterval('P15D'));' is possible, but it > has the same problem. > > I have to write: > > $date = new DateTime() > $date->add(new DateInterval('P' . getDaysToAddMethod() . 'D')); > > I think it is very hard to read. Or is it just my personal point of view? I agree it's unintuitive. Rather than the original: $date->modify(15, DateTime::INTERVAL_DAY); What about adding such option to DateInterval constructor? new DateInterval(DateTime::INTERVAL_DAY, 15); Or maybe: new DateInterval( array( DateTime::INTERVAL_DAY=> 15 ) );

« previous php.internals (#64234) next »