Bug #78241 [Opn->Csd]: touch() does not handle dates after 2038 in PHP 64-bit
| From: | cmb@php.net | Date: | Wed, 03 Jul 2019 08:04:42 +0000 |
| Subject: | Bug #78241 [Opn->Csd]: touch() does not handle dates after 2038 in PHP 64-bit | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-221599@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78241&edit=1
ID: 78241
Updated by: cmb@php.net
Reported by: goozak at gmail dot com
Summary: touch() does not handle dates after 2038 in PHP
64-bit
-Status: Open
+Status: Closed
Type: Bug
Package: Filesystem function related
Operating System: Windows 10
PHP Version: 7.2.20RC3
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=44c8b7414ce96038017edc2fd827f8250669a62a
Log: Fix #78241: touch() does not handle dates after 2038 in PHP 64-bit
Previous Comments:
------------------------------------------------------------------------
[2019-07-02 18:40:42] requinix@php.net
Same for 7.3. However 7.4alpha2 shows 22 Apr 60358...
------------------------------------------------------------------------
[2019-07-02 18:09:25] goozak at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=78241&edit=1