3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.2.1 - 5.2.3, 5.3.0 - 5.6.28, 7.0.0 - 7.1.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 hhvm-3.12.0
Testfile is '/tmp/test-filemtime'. Testfile 'test-filemtime' mtime should be from touch 0, is 1474260736. The mtime represents Mon, 19 Sep 2016 06:52:16 +0200 Testfile 'test-filemtime' mtime should be from touch 1408892400, is 1408892400. The mtime represents Sun, 24 Aug 2014 17:00:00 +0200
Output for hhvm-3.10.0
Testfile is '/tmp/test-filemtime'. Testfile 'test-filemtime' mtime should be from touch 0, is 1474260735. The mtime represents Mon, 19 Sep 2016 06:52:15 +0200 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.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.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