Re: DateTime::modify('now') is ignored, why?

From: Date: Mon, 26 Nov 2012 12:02:50 +0000
Subject: Re: DateTime::modify('now') is ignored, why?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-64048@lists.php.net to get a copy of this message
On Mon, 26 Nov 2012, Ivan Enderlin @ Hoa wrote: > On 26/11/12 12:25, Sebastian Krebs wrote: > > 2012/11/26 Ivan Enderlin @ Hoa <ivan.enderlin@hoa-project.net> > > > > > I would to modify a \DateTime object to the current time, thus I wrote > > > this: > > > > > > $d = new \DateTime('+1 hour'); > > > $d->modify('now'); > > > > > > It did not work. Why? Because the documentation (http://php.net/datetime.* > > > *formats.relative > > > <http://php.net/datetime.formats.relative>) says: “Now > > > - this is simply ignored”. Really? But the behavior is pretty > > > straightforward isn't? “modify to now” means “set to the current date and > > > time and let the timezone unchanged”. > > > > > It's not like "modify to something", but "modify _with_ > > something". With > > your point of view "modifiy('+7 days')" will _always_ point to next > > week, > > but it should (and it's intuitive right), that it will point to 7 days > > after the previous date. So what should "modify with now" mean? > I understand the different, but then, why “now” is declared in the > documentation :-) ? Because people (like you) have tried it before and found it to not do as they thought :-) Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine

« previous php.internals (#64048) next »