ID: 49534 User updated by: re dot lewis at comcast dot net Reported By: re dot lewis at comcast dot net Status: Bogus Bug Type: Date/time related Operating System: Linux PHP Version: 5.2.10 New Comment:
Thanks for setting me straight. Previous Comments: ------------------------------------------------------------------------ [2009-09-11 19:27:24] [email protected] Which would be why it isn't a bug. Start with a timestamp around noon to avoid DST issues like this. You probably also want to use something like this instead: $db = new DateTime('2008-12-31'); $de = new DateTime('2009-12-31'); $di = DateInterval::createFromDateString('Sunday next week'); $dp = new DatePeriod($db, $di, $de, DatePeriod::EXCLUDE_START_DATE); foreach($dp as $dt) { echo $dt->format("F jS\n") . "<br>\n"; } This would give you the date of each Sunday in 2009, except the first one (because of the EXCLUDE_START_DATE) option. ------------------------------------------------------------------------ [2009-09-11 19:21:02] re dot lewis at comcast dot net Description: ------------ On Sept 11, 2009 I was calculating the date for each successive sunday and used the code below, but after Nov 1, 2009, the day changes to Saturday. Is this a bug? It appears to be related to daylight savings time. Reproduce code: --------------- <?php for ($w= 5; $w < 15; $w++) { echo date('Y-m-d, D, z', (strtotime('sunday') + $w*7*24*60*60)) . "<br>"; } ?> Expected result: ---------------- Return the date of each sunday starting 5 weeks from this coming sunday. Actual result: -------------- 2009-10-18, Sun, 290 2009-10-25, Sun, 297 2009-11-01, Sun, 304 2009-11-07, Sat, 310 2009-11-14, Sat, 317 2009-11-21, Sat, 324 2009-11-28, Sat, 331 2009-12-05, Sat, 338 2009-12-12, Sat, 345 2009-12-19, Sat, 352 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49534&edit=1
