note 104382 deleted from function.filemtime by danbrown
| From: | danbrown@php.net | Date: | Sun, 12 Jun 2011 23:21:35 +0000 |
| Subject: | note 104382 deleted from function.filemtime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180463@lists.php.net to get a copy of this message | ||
Note Submitter: Springtime Software
----
myselfasunder's code is an excellent workaround for the DST bug under Windows. However, it is
correct in most of the USA only for files last modified in 2007 or later. For files created or
modified before that date, the USA DST rules were different, so errors (differences with the local
time that is reported by Windows) can still occur (the "I" format of the date function
also shows the same error due to DST rule changes). For the USA, these errors happen for certain
days in the months of March and November, which were the only months affected by the 2007 DST rules
change.
Note that Linux may not track such multiple DST rule changes adequately for the user's
location, so this is not just a Windows problem. The problem is also not limited to users located in
the USA.
An adequate fix will require taking the date/time modified of the file and the DST rules of the
user's locality, over their entire history, fully into account, along with the peculiarities of
the underlying operating system (including its version).
It is unlikely that individual operating systems will ever be fixed to reflect multiple DST rules
and multiple user locations, which would be the solution in an ideal world. If someone were to
research and develop a good general solution, it would be wonderful to add it to PHP itself, saving
the need for all programmers needing this function from having to research and develop their own
limited workarounds. This would clearly add value to PHP as being one of the only places in the
world of computing where DST was handled correctly.
A general solution is possible, but would not be easy: it would be based on a table containing
complete DST rule histories for many localities around the world. It would also require a table of
all OS peculiarities in calculating Unix Epoch times (UTC cannot be used to compute local time,
bypassing OS peculiarities, since Linux, for example, stores dates/times only in Epoch time).
Such a complete solution would need to be applied to all PHP functions that are subject to
DST-related errors.
Reference: http://en.wikipedia.org/wiki/Daylight_saving_time,
sections Tz database and Microsoft Windows.