Created
January 14, 2012 22:56
-
-
Save PeterJCLaw/1613263 to your computer and use it in GitHub Desktop.
Testing PHP's touch and fileXtime functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $file = 'bacon'; | |
| $dateFormat = 'F d Y H:i:s.u'; | |
| unlink($file); | |
| var_dump(file_put_contents($file, rand())); | |
| echo 'atime: '; var_dump(date($dateFormat, fileatime($file))); | |
| echo 'ctime: '; var_dump(date($dateFormat, filectime($file))); | |
| echo 'mtime: '; var_dump(date($dateFormat, filemtime($file))); | |
| $touchTime = mktime(1,1,1); | |
| echo 'touch Time: ', date($dateFormat, $touchTime), PHP_EOL; | |
| var_dump(touch($file, $touchTime)); | |
| sleep(1); | |
| echo 'atime: '; var_dump(date($dateFormat, fileatime($file))); | |
| echo 'ctime: '; var_dump(date($dateFormat, filectime($file))); | |
| echo 'mtime: '; var_dump(date($dateFormat, filemtime($file))); | |
| //*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int(9) | |
| atime: string(31) "January 14 2012 22:57:01.000000" | |
| ctime: string(31) "January 14 2012 22:57:01.000000" | |
| mtime: string(31) "January 14 2012 22:57:01.000000" | |
| touch Time: January 14 2012 01:01:01.000000 | |
| bool(true) | |
| atime: string(31) "January 14 2012 22:57:01.000000" | |
| ctime: string(31) "January 14 2012 22:57:01.000000" | |
| mtime: string(31) "January 14 2012 22:57:01.000000" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment