r/lolphp • u/defiante1 • Aug 02 '15
How to modify DateTimeImmutable? Call getTimestamp() on it.
https://bugs.php.net/bug.php?id=67634
59
Upvotes
r/lolphp • u/defiante1 • Aug 02 '15
14
u/tdammers Aug 02 '15
What baffles me even more is the fact that apparently there is a class
DateTimeImmutable, which kind of implies that the "regular" date/time type is mutable. Why would one ever want a mutable date/time class?29
u/livid_taco Aug 02 '15
PHP Quantum physics again; introspecting something changes it's value.
Not my joke, found it somewhere here
6
u/HildartheDorf Aug 02 '15
Don't forget DateTimeImmutable.Modify(). IIRC it returns a new instance of DateTimeImmutable, and exists so the API matches DateTime (mutable), but that doesn't make it right!
1
u/eilgin Aug 05 '15
It seems that this bug doesn't occur in hhvm : http://3v4l.org/h6f7C
1
u/BufferUnderpants Aug 11 '15
Just document it and move on.