date - PHP Daylight savings bug? -


i ran strange bug has occurs in php running in pacific time (and others). had code first day of week (sunday) given arbitrary date (in unix timestamp) in week:

$day = date('w', $date); $start_of_week = date('y-m-d', $date - ($day * 60*60*24)); echo $start_of_week; 

prints 2014-03-08

this works every single date i've tried, except in week of march 9th, 2014, happens week of daylight savings time in us. those, $start_of_week '2014-03-08', saturday.

when run code timezone set gmt, correct output ('2014-03-09').

additionally, when change code following in pst, correct output:

$day = date('w', $date); $start_of_week = date('y-m-d', strtotime("-$day day", $date)); echo $start_of_week; 

prints 2014-03-09

so...wtf? why there difference between strtotime("-1 day", $date) , $date - 60*60*24? seems it's jumping between different timezones.

codepad example


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -