From: RQuadling at GMail dot com
Operating system: Windows XP SP3
PHP version: 5.3CVS-2009-05-12 (snap)
PHP Bug Type: Date/time related
Bug description: Setting file datetime outside of matching DST settings loses
time.
Description:
------------
Touching a file with a non DST datetime and then reading it back is
losing 1 hour.
Using Procmon, Windows is getting and returning the correct times.
It seems that PHP is adjusting the times it gets when in DST and
reading a file NOT in DST.
Reproduce code:
---------------
<?php
// Create a dummy file.
$s_File = getenv('TEMP') . DIRECTORY_SEPARATOR . 'junktime.txt';
file_put_contents($s_File, 'JUNK');
$a_Dates = array(
'Some time today' => strtotime('today 13:14:15'),
'January 1st' => strtotime('2009/02/03 04:05:06'),
'October 1st' => strtotime('2008/10/01 04:05:06'),
);
foreach($a_Dates as $s_When => $dt_Date) {
touch($s_File, $dt_Date);
clearstatcache();
$dt_Modified = filemtime($s_File);
echo
'Wanted to set the date to : (', $dt_Date, ') ', date('r', $dt_Date),
PHP_EOL,
'File was set to : (', $dt_Modified, ') ', date('r',
$dt_Modified), PHP_EOL,
($dt_Date === $dt_Modified ? 'Match' : 'Different'), PHP_EOL,
PHP_EOL;
}
// Clean-up
unlink($s_File);
Expected result:
----------------
Wanted to set the date to : (1242130455) Tue, 12 May 2009 13:14:15
+0100
File was set to : (1242130455) Tue, 12 May 2009 13:14:15
+0100
Match
Wanted to set the date to : (1233633906) Tue, 03 Feb 2009 04:05:06
+0000
File was set to : (1233633906) Tue, 03 Feb 2009 04:05:06
+0000
Match
Wanted to set the date to : (1222830306) Wed, 01 Oct 2008 04:05:06
+0100
File was set to : (1222830306) Wed, 01 Oct 2008 04:05:06
+0100
Match
Actual result:
--------------
Wanted to set the date to : (1242130455) Tue, 12 May 2009 13:14:15
+0100
File was set to : (1242130455) Tue, 12 May 2009 13:14:15
+0100
Match
Wanted to set the date to : (1233633906) Tue, 03 Feb 2009 04:05:06
+0000
File was set to : (1233630306) Tue, 03 Feb 2009 03:05:06
+0000
Different
Wanted to set the date to : (1222830306) Wed, 01 Oct 2008 04:05:06
+0100
File was set to : (1222830306) Wed, 01 Oct 2008 04:05:06
+0100
Match
--
Edit bug report at http://bugs.php.net/?id=48245&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48245&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48245&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48245&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48245&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48245&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48245&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48245&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48245&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48245&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48245&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48245&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48245&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48245&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48245&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48245&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48245&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48245&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48245&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48245&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48245&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48245&r=mysqlcfg