What is the function in PHP 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 time when the data blocks of a file were being written to, which is usually the last modification time. You can pass the file path as a parameter to the `filemtime()` function to get the modification date in Unix timestamp format.
$file = 'example.txt';
$modification_date = filemtime($file);
echo "Last modified: " . date("F d Y H:i:s.", $modification_date);
Keywords
Related Questions
- What steps can be taken to ensure that session management in PHP is secure and reliable, especially when dealing with multiple users accessing the same application simultaneously?
- What are the best practices for ensuring that the names associated with IDs are displayed correctly in PHP-generated emails?
- What are the drawbacks of manually listing every included page in PHP, and what alternative solutions exist?