Re: Improve DateTime Class
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 ) );
Thread (9 messages)