DateTime works as it should. If you are not in an area that has observed various DSTs in a larger area, America/Los_Angeles left DST (PDT-> PST) on November 6th (in 2016).
https://www.timeanddate.com/news/time/usa-canada-end-dst-2016.html
In timezeonedb you can view the dates it uses by doing an array search for your specific date / time (which Machavity did) and getting the fact that it is not in DST, and then continuing to change it manually. This is not an answer, as it will ultimately fail unless you manually add a cutoff time for manual correction to stop.
Checking the transition date around your date shows:
date_default_timezone_set('America/Los_Angeles'); $theDate = new DateTime("2016-11-07T17:30:00",new DateTimeZone("America/Los_Angeles")); $theDateBefore = new DateTime("2016-03-01"); $theDateAfter = new DateTime("2017-03-15"); echo "<pre>"; print_r( $theDate->getTimezone()->getTransitions( $theDateBefore->getTimestamp(),$theDateAfter->getTimestamp())); echo "</pre>";
the result is an array of 4:
Array ( [0] => Array ( [ts] => 1456819200 [time] => 2016-03-01T08:00:00+0000 [offset] => -28800 [isdst] => [abbr] => PST ) [1] => Array ( [ts] => 1457863200 [time] => 2016-03-13T10:00:00+0000 [offset] => -25200 [isdst] => 1 [abbr] => PDT ) [2] => Array ( [ts] => 1478422800 [time] => 2016-11-06T09:00:00+0000 [offset] => -28800 [isdst] => [abbr] => PST ) [3] => Array ( [ts] => 1489312800 [time] => 2017-03-12T10:00:00+0000 [offset] => -25200 [isdst] => 1 [abbr] => PDT ) )
Array [0] is a time zone that acts like theDateBefore , and you can see that date changes apply to your time.
Your sale date falls after changing from PDT to PST.
To return the correct date / time code, you need to manually change it. The implementation of this method, which was adopted, would give false results. As I mentioned, you will need to surround this with what you want the user timezone to be enabled.
source share