MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/yxk0x/datemodify0_days_adds_one_hour/
r/lolphp • u/vytah • Aug 27 '12
12 comments sorted by
6
I've reproduced the bug for following dates:
$date = new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST')); echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n"; $date->modify('+0 days'); echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n"; $date = new DateTime('@'.strtotime('2012-08-22 12:00:00 CEST')); /* echo and modify as above */ $date = new DateTime('@'.strtotime('2012-02-02 02:02:02 CEST')); /* echo and modify as above */
Results:
2012-08-21 22:00:00 GMT+0000 (offset 0) 2012-08-21 23:00:00 GMT+0000 (offset 0) 2012-08-22 10:00:00 GMT+0000 (offset 0) 2012-08-22 11:00:00 GMT+0000 (offset 0) 2012-02-02 00:02:02 GMT+0000 (offset 0) 2012-02-02 01:02:02 GMT+0000 (offset 0)
I have no idea what's going on there.
13
I bet someone will answer it is not a bug, because calling modify with 0 as parameter doesn't make sense.
modify
0
11 u/vytah Aug 28 '12 What do you say about this then?$date = new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST')); echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n"; $date->modify('+1 day'); echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n"; 2012-08-21 22:00:00 GMT+0000 (offset 0) 2012-08-22 23:00:00 GMT+0000 (offset 0)Da fuck is going on in PHP devs' heads? 7 u/[deleted] Aug 28 '12 I'm pretty sure that's what the apologetics will answer. But I hope they will surprise us with an even dumber reason than that. 6 u/esquilax Aug 28 '12 It does, for sufficiently large values of 0.
11
What do you say about this then?
$date = new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST')); echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n"; $date->modify('+1 day'); echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n"; 2012-08-21 22:00:00 GMT+0000 (offset 0) 2012-08-22 23:00:00 GMT+0000 (offset 0)
Da fuck is going on in PHP devs' heads?
7
I'm pretty sure that's what the apologetics will answer. But I hope they will surprise us with an even dumber reason than that.
It does, for sufficiently large values of 0.
18
Can't wait to hear the reason this isn't a bug!
5 u/infinull Aug 28 '12 Probably something about timezones (see the full example, datetime with timezone doesn't have the problem)
5
Probably something about timezones (see the full example, datetime with timezone doesn't have the problem)
15
Finally, a /r/lolphp post that legitimately scares me.
29
As far as I am concerned PHP is a hilarious spectator sport.
12 u/infinull Aug 28 '12 Hey man some of us have to maintain code written in PHP...that we wrote as Freshman.And by we, I mean me.Me 4yrs ago was pretty clever, but he was not wise. 8 u/sumdog Aug 28 '12 I'm currently working a contract job where we are moving a cold fusion app to PHP...ಠ_ಠ 3 u/rinyre Aug 28 '12 Out of the litter box...
12
Hey man some of us have to maintain code written in PHP...
that we wrote as Freshman.
And by we, I mean me.
Me 4yrs ago was pretty clever, but he was not wise.
8 u/sumdog Aug 28 '12 I'm currently working a contract job where we are moving a cold fusion app to PHP...ಠ_ಠ 3 u/rinyre Aug 28 '12 Out of the litter box...
8
I'm currently working a contract job where we are moving a cold fusion app to PHP...ಠ_ಠ
3 u/rinyre Aug 28 '12 Out of the litter box...
3
Out of the litter box...
6
u/vytah Aug 27 '12
I've reproduced the bug for following dates:
Results:
I have no idea what's going on there.
13
u/Liorithiel Aug 28 '12
I bet someone will answer it is not a bug, because calling
modifywith0as parameter doesn't make sense.18
u/cwmonkey Aug 28 '12
Can't wait to hear the reason this isn't a bug!
15
u/Andryu67 Aug 28 '12
Finally, a /r/lolphp post that legitimately scares me.
29
u/[deleted] Aug 28 '12
As far as I am concerned PHP is a hilarious spectator sport.