|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-13 08:28 UTC] RQuadling at GMail dot com
[2009-05-13 08:30 UTC] RQuadling at GMail dot com
[2009-06-10 13:04 UTC] jani@php.net
[2009-06-10 14:00 UTC] RQuadling at GMail dot com
[2009-06-18 15:23 UTC] pajoye@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 16:00:02 2025 UTC |
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