3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * test that filemtime() returns Unix timestamp (UTC) on current system */ $timestampStartOfUnixEpoch = 0; // start of the Unix epoch. $timestampRequest = 3600 * (int) ($_SERVER['REQUEST_TIME'] / 3600); $testFile = sprintf('%s/%s', sys_get_temp_dir(), 'test-filemtime'); printf("Testfile is '%s'.\n", $testFile); touch($testFile, $timestampStartOfUnixEpoch); clearstatcache(false, $testFile); $mtime = filemtime($testFile); printf("Testfile '%s' mtime should be from touch %d, is %d.\n", basename($testFile), $timestampStartOfUnixEpoch, $mtime); printf("The mtime represents %s\n", date('r', $mtime)); touch($testFile, $timestampRequest); clearstatcache(false, $testFile); $mtime = filemtime($testFile); printf("Testfile '%s' mtime should be from touch %d, is %d.\n", basename($testFile), $timestampRequest, $mtime); printf("The mtime represents %s\n", date('r', $mtime)); unlink($testFile);
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Testfile is '/tmp/test-filemtime'. Testfile 'test-filemtime' mtime should be from touch 0, is 1408895880. The mtime represents Sun, 24 Aug 2014 17:58:00 +0200 Testfile 'test-filemtime' mtime should be from touch 1408892400, is 1408895880. The mtime represents Sun, 24 Aug 2014 17:58:00 +0200
Output for 7.3.32 - 7.3.33, 8.0.13
Testfile is '/tmp/test-filemtime'. Testfile 'test-filemtime' mtime should be from touch 0, is 1408895880. The mtime represents Sun, 24 Aug 2014 15:58:00 +0000 Testfile 'test-filemtime' mtime should be from touch 1408892400, is 1408895880. The mtime represents Sun, 24 Aug 2014 15:58:00 +0000
Output for 5.2.1 - 5.2.3, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.17, 7.2.19 - 7.2.24, 7.3.0 - 7.3.12, 7.4.0
Testfile is '/tmp/test-filemtime'. Testfile 'test-filemtime' mtime should be from touch 0, is 0. The mtime represents Thu, 01 Jan 1970 01:00:00 +0100 Testfile 'test-filemtime' mtime should be from touch 1408892400, is 1408892400. The mtime represents Sun, 24 Aug 2014 17:00:00 +0200
Output for 7.2.18
Testfile is '/tmp/test-filemtime'. Warning: filemtime(): stat failed for /tmp/test-filemtime in /in/aaVh3 on line 15 Testfile 'test-filemtime' mtime should be from touch 0, is 0. The mtime represents Thu, 01 Jan 1970 01:00:00 +0100 Testfile 'test-filemtime' mtime should be from touch 1408892400, is 1408892400. The mtime represents Sun, 24 Aug 2014 17:00:00 +0200
Output for 5.2.4 - 5.2.17
Testfile is '/tmp/test-filemtime'. Warning: Wrong parameter count for clearstatcache() in /in/aaVh3 on line 14 Testfile 'test-filemtime' mtime should be from touch 0, is 0. The mtime represents Thu, 01 Jan 1970 01:00:00 +0100 Warning: Wrong parameter count for clearstatcache() in /in/aaVh3 on line 20 Testfile 'test-filemtime' mtime should be from touch 1408892400, is 0. The mtime represents Thu, 01 Jan 1970 01:00:00 +0100
Output for 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function sys_get_temp_dir() in /in/aaVh3 on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Notice: Undefined index: REQUEST_TIME in /in/aaVh3 on line 7 Fatal error: Call to undefined function sys_get_temp_dir() in /in/aaVh3 on line 9
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Undefined index: REQUEST_TIME in /in/aaVh3 on line 7 Fatal error: Call to undefined function: sys_get_temp_dir() in /in/aaVh3 on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Notice: Undefined index: REQUEST_TIME in /in/aaVh3 on line 7 Fatal error: Call to undefined function: sys_get_temp_dir() in /in/aaVh3 on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Undefined index: REQUEST_TIME in /in/aaVh3 on line 7 Fatal error: Call to undefined function: sys_get_temp_dir() in /in/aaVh3 on line 9

preferences:
252.44 ms | 401 KiB | 398 Q