The filemtime() function in PHP is an inbuilt function which is used to return the last time of a specified file when its content was modified. The filemtime() function returns the last time the file was changed as a Unix Timestamp on success and False on failure.
The filename is passed as a parameter to the filemtime() function. The result of the filemtime() function is cached and a function called clearstatcache() is used to clear the cache.
Parameters: The filemtime() function in PHP accepts only one parameter $filename. It specifies the file which you want to check.
Return Value: It returns the last time of a file when its content was modified as a Unix Timestamp on success and False on failure.
Errors And Exception:
- The time resolution may differ from one file system to another.
- This function doesn’t works on some unix systems which have access time updates are disabled to increase performance.
Input : echo filemtime("gfg.txt"); Output : 1525159574 Input : echo "Last modified: ".date("F d Y H:i:s.", filemtime("gfg.txt")); Output : Last modified: May 1 2018 07:26:14.
Below programs illustrate the filemtime() function.
1525159574 Last modified: May 1 2018 07:26:14.
- How to get the function name inside a function in PHP ?
- p5.js | nfp() Function
- p5.js | nf() Function
- p5.js | nfc() function
- p5.js | nfs() Function
- PHP | pos() Function
- PHP | key() Function
- PHP | Ds\Set xor() Function
- PHP | Ds\Map map() Function
- PHP | Ds\Map last() Function
- p5.js | arc() Function
- PHP | end() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.