Bug #78241 [NEW]: touch() does not handle dates after 2038 in PHP 64-bit
| From: | goozak at gmail dot com | Date: | Tue, 02 Jul 2019 18:09:25 +0000 |
| Subject: | Bug #78241 [NEW]: touch() does not handle dates after 2038 in PHP 64-bit | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-221586@lists.php.net to get a copy of this message | ||
From: goozak at gmail dot com
Operating system: Windows 10
PHP version: 7.2.20RC3
Package: Filesystem function related
Bug Type: Bug
Bug description:touch() does not handle dates after 2038 in PHP 64-bit
Description:
------------
On PHP 7.2.20 64-bit, on Windows, touch() cannot set a file's date to a
date after 2038. filemtime() will read such a file's date fine (date was
set with an external tool).
Test script:
---------------
<pre><?php
$filename = 'C:\\Test\\TestFile.txt';
for ($i = 2037; $i <= 2040; $i++) {
$t = mktime(1,1,1,1,1,$i);
echo 'Date: '.date('D, d M Y H:i:s', $t).'<br>';
touch($filename, $t);
clearstatcache(true, $filename);
$file = filemtime($filename);
// This will be wrong for 2039 and 2040
echo 'File: '.date('D, d M Y H:i:s', $file).'<br><br>';
}
?></pre>
Expected result:
----------------
Date: Thu, 01 Jan 2037 01:01:01
File: Thu, 01 Jan 2037 01:01:01
Date: Fri, 01 Jan 2038 01:01:01
File: Fri, 01 Jan 2038 01:01:01
Date: Sat, 01 Jan 2039 01:01:01
File: Sat, 01 Jan 2039 01:01:01
Date: Sun, 01 Jan 2040 01:01:01
File: Sun, 01 Jan 2040 01:01:01
Actual result:
--------------
Date: Thu, 01 Jan 2037 01:01:01
File: Thu, 01 Jan 2037 01:01:01
Date: Fri, 01 Jan 2038 01:01:01
File: Fri, 01 Jan 2038 01:01:01
Date: Sat, 01 Jan 2039 01:01:01
File: Tue, 25 Nov 1902 18:32:45 <--- Wrong!
Date: Sun, 01 Jan 2040 01:01:01
File: Wed, 25 Nov 1903 18:32:45 <--- Wrong!
--
Edit bug report at https://bugs.php.net/bug.php?id=78241&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78241&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78241&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78241&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78241&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78241&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78241&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78241&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78241&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78241&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78241&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78241&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78241&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78241&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78241&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78241&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78241&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78241&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78241&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78241&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78241&r=mysqlcfg