News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Daniel Cousineau's Blog:
Calculating Daylight Savings Time Boundary In PHP
March 11, 2009 @ 12:02:15

Daniel Cousineau has written up some timely advice in a new post to his blog. It looks at pinpointing the time boundary for Daylight Savings Time in a PHP script (when it starts and when it ends).

I had an issue recently where I needed to calculate the Unix timestamp for the daylight savings time boundaries. According to the United States Naval Observatory, daylight savings time begins the Second Sunday of March and ends on the First Sunday of November.

He looks at using the strtotime function to calculate these dates but points out some quirks - like what happens when you just give it a month or something like "second Sunday". His solution was to go back one day ("March 0" instead of "March 1") and calculating the time from there, including that first full day of March in the calculation.

0 comments voice your opinion now!
calculate daylight savings time boundary march november strtotime


blog comments powered by Disqus

Similar Posts

Kore Nordmann's Blog: eZ Components book in the press

David Goodwin's Blog: PHP DateTime vs mktime / strtotime in Propel

Paul Reinheimer's Blog: 20/20 6:40 (or Pecha Kucha)

Leon Chevalier's Blog: Improve website load time by 500% with 3 lines of code

PHP Security Blog: Month of PHP Bugs and PHP 5.2.1


Community Events











Don't see your event here?
Let us know!


symfony2 package application database composer unittest hhvm hack introduction support framework podcast performance facebook language opinion release install security component

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework