What potential pitfalls should be considered when retrieving and displaying file modification dates in PHP?

When retrieving and displaying file modification dates in PHP, one potential pitfall to consider is the timezone settings. If the timezone is not set correctly, the displayed modification dates may be inaccurate. To ensure the correct timezone is used, it is recommended to set it explicitly in the PHP script.

// Set the timezone to the desired value
date_default_timezone_set('America/New_York');

// Retrieve and display the file modification date
$filePath = 'example.txt';
$modificationDate = date("Y-m-d H:i:s", filemtime($filePath));
echo "Last modified: $modificationDate";