Hi internals,
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) 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”.
Thoughts?
Best regards.
--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/
PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/
Member of HTML and WebApps Working Group of W3C
http://w3.org/
2012/11/26 Ivan Enderlin @ Hoa ivan.enderlin@hoa-project.net
Hi internals,
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?
Other way round: You are looking for the "set*()"-methods :) Because you
want to set a date, not modify one.
Regards,
Sebastian
Thoughts?
Best regards.--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/Member of HTML and WebApps Working Group of W3C
http://w3.org/--
Hi Sebastien,
2012/11/26 Ivan Enderlin @ Hoa ivan.enderlin@hoa-project.net
Hi internals,
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 :-) ?
Other way round: You are looking for the "set*()"-methods :) Because you
want to set a date, not modify one.
Exactly, setTimestamp(time()) resolved by problem.
Best regards.
--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/
PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/
Member of HTML and WebApps Working Group of W3C
http://w3.org/
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
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 :-)
It would have been better never write this keyword ;-).
Thanks.
Have a good day.
PS: In the french version of the documentation, the "it is ignored" was
missing. I have submitted a patch.
--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/
PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/
Member of HTML and WebApps Working Group of W3C
http://w3.org/
On Mon, 26 Nov 2012 15:06:09 +0400, Ivan Enderlin @ Hoa
ivan.enderlin@hoa-project.net wrote:
Hi internals,
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) 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”.Thoughts?
Best regards.
Shouldn't DateTime be immutable? What's the point of DateTime object being
mutable?
I would include my point about why DateTime should be immutable but I even
can't come with any points except OO-logic and all I can say is I just
feel like mutable DateTime is wrong. What you think about it?
PS I'm not Nikita Popov (aka nikic) :)
On Mon, 26 Nov 2012 15:06:09 +0400, Ivan Enderlin @ Hoa
ivan.enderlin@hoa-project.net wrote: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) 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”.Shouldn't DateTime be immutable? What's the point of DateTime object
being mutable? I would include my point about why DateTime should be
immutable but I even can't come with any points except OO-logic and
all I can say is I just feel like mutable DateTime is wrong. What you
think about it?
Yes, it should have been immutable. Biggest mistake that I made in this
API. We can't change it anymore though.
cheers,
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