xref: /PHP-8.4/ext/standard/tests/file/bug78241.phpt (revision 821f6bb5)
1--TEST--
2Bug #78241 (touch() does not handle dates after 2038 in PHP 64-bit)
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') die('skip this test is for Windows platforms only');
6if (PHP_INT_SIZE != 8) die('skip this test is for 64bit platforms only');
7?>
8--INI--
9date.timezone=UTC
10--FILE--
11<?php
12$filename = __DIR__ . '/bug78241.txt';
13for ($i = 2037; $i <= 2040; $i++) {
14  $t = mktime(1, 1 , 1, 1, 1, $i);
15  echo 'Date: '.date('D, d M Y H:i:s', $t), PHP_EOL;
16  touch($filename, $t);
17  clearstatcache(true, $filename);
18  $file = filemtime($filename);
19  echo 'File: '.date('D, d M Y H:i:s', $file), PHP_EOL, PHP_EOL;
20}
21?>
22--CLEAN--
23<?php
24@unlink($filename = __DIR__ . '/bug78241.txt');
25?>
26--EXPECT--
27Date: Thu, 01 Jan 2037 01:01:01
28File: Thu, 01 Jan 2037 01:01:01
29
30Date: Fri, 01 Jan 2038 01:01:01
31File: Fri, 01 Jan 2038 01:01:01
32
33Date: Sat, 01 Jan 2039 01:01:01
34File: Sat, 01 Jan 2039 01:01:01
35
36Date: Sun, 01 Jan 2040 01:01:01
37File: Sun, 01 Jan 2040 01:01:01
38