From: JPlissonneauDuquene at bellhelicopter dot textron dot com Operating system: Windows XP PHP version: 5.2.1 PHP Bug Type: Filesystem function related Bug description: filemtime shifted by one hour on win32
Description: ------------ Hi, PHP filemtime/fileatime/filectime (and maybe stat itself) functions should use GetFileTime() Win32API (or GetFileAttributesEx()), not stat() to retrieve the actual times from files. Otherwise the returned time is shifted by one hour in some conditions. This (mis)behaviour is actually DOCUMENTED by Microsoft, so it does not qualify for "bogus - fix microsoft libraries" bug rejection -- Microsoft already fixed their documentation and even indicated that "This behavior is by design." References: http://support.microsoft.com/kb/158588 http://support.microsoft.com/kb/190315 http://msdn2.microsoft.com/en-gb/library/ms724290.aspx http://us3.php.net/manual/en/function.stat.php#58404 http://www.codeproject.com/datetime/dstbugs.asp Thanks! Reproduce code: --------------- <?php print date(DATE_ISO8601) . ' ' . time() . "\r\n"; $summer_date = gmmktime(12,34,56,06,21,2006); $winter_date = gmmktime(12,34,56,12,21,2006); if (!file_exists("summer_file")) touch("summer_file", $summer_date); if (!file_exists("winter_file")) touch("winter_file", $winter_date); print "summer_file " . $summer_date . ' ' . filemtime("summer_file") . "\r\n"; print "winter_file " . $winter_date . ' ' . filemtime("winter_file") . "\r\n"; ?> Expected result: ---------------- D:\test>php test.php 2007-02-20T15:14:45-0500 1172002485 summer_file 1150893296 1150893296 winter_file 1166704496 1166704496 D:\test>dir 06/21/2006 08:34 AM 0 summer_file 12/21/2006 07:34 AM 0 winter_file Actual result: -------------- # NOTE - run tests in order. Test 1 will create the files. # Do NOT remove the files before tests 2-4. # test 1. Winter time, DST adj. checked D:\test>php test.php 2007-02-20T17:07:47-0500 1172009267 summer_file 1150893296 1150893296 winter_file 1166704496 1166704496 # test 2. Winter time, DST adj. unchecked D:\test>php test.php 2007-02-20T17:08:05-0500 1172009285 summer_file 1150893296 1150896896 winter_file 1166704496 1166704496 # note summer_file timestamp is now 1 hour later # test 3. Summer time, DST adj. unchecked D:\test>php test.php 2007-08-20T18:08:34-0400 1187647714 summer_file 1150893296 1150896896 winter_file 1166704496 1166704496 # same as test 2. # note that time /t or GUI clock will show 17:08, while # PHP time reports 18:08, but this is another bug. # test 4. Summer time, DST adj. now checked D:\test>php test.php 2007-08-20T18:11:04-0400 1187647864 summer_file 1150893296 1150896896 winter_file 1166704496 1166708096 # note that winter_file timestamp is now 1 hour later # time /t and GUI clock jumped 1 hour later (18:11) when # checking automatic DST adj. D:\test>dir *_file # after test1 06/21/2006 08:34 AM 0 summer_file 12/21/2006 07:34 AM 0 winter_file # after test2 06/21/2006 08:34 AM 0 summer_file 12/21/2006 07:34 AM 0 winter_file # after test3 06/21/2006 08:34 AM 0 summer_file 12/21/2006 07:34 AM 0 winter_file # after test4 06/21/2006 09:34 AM 0 summer_file 12/21/2006 08:34 AM 0 winter_file -- Edit bug report at http://bugs.php.net/?id=40568&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40568&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40568&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40568&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40568&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40568&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40568&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40568&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40568&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40568&r=support Expected behavior: http://bugs.php.net/fix.php?id=40568&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40568&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40568&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40568&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40568&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40568&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40568&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40568&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40568&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40568&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40568&r=mysqlcfg