xref: /PHP-7.4/ext/standard/tests/file/bug78241.phpt (revision 44c8b741)
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--EXPECT--
23Date: Thu, 01 Jan 2037 01:01:01
24File: Thu, 01 Jan 2037 01:01:01
25
26Date: Fri, 01 Jan 2038 01:01:01
27File: Fri, 01 Jan 2038 01:01:01
28
29Date: Sat, 01 Jan 2039 01:01:01
30File: Sat, 01 Jan 2039 01:01:01
31
32Date: Sun, 01 Jan 2040 01:01:01
33File: Sun, 01 Jan 2040 01:01:01
34