What PHP function can be used to retrieve the modification date of a file?
To retrieve the modification date of a file in PHP, you can use the `filemtime()` function. This function returns the Unix timestamp of when the file was last modified. You can then use the `date()` function to format this timestamp into a human-readable date format.
$filename = 'example.txt';
$modification_date = filemtime($filename);
$formatted_date = date("Y-m-d H:i:s", $modification_date);
echo "The file $filename was last modified on: $formatted_date";
Keywords
Related Questions
- What is the significance of using print_r function in debugging PHP code?
- How can PHP developers ensure that numeric values are correctly parsed and casted to the desired data type?
- How does PHP access the correct table in a database and what are the potential pitfalls when defining table names in PHP code?