I am trying to echo the file’s last updated time and show it as an ISO-8601 timestamp format. I tried some commands, but they didn’t get the right last modified date.
I tried:
<?php echo date("c"); ?>
But it only gets the current server time, like 2024-01-11T11:39:33+02:00, which is always changing. Same as date('c', time()).
The following two seem to get the following date: 1970-01-01T02:00:00+02:00:
$lastmod = date('Y-m-dTH:i:s+00:00');
echo date('c', $timestamp)
and
$lastmod = date('Y-m-dTH:i:s'); $tzd = date('Z'); $lastmod .= ($tzd < 0)? "-".gmdate('H:i', -$tzd) : "+".gmdate('H:i', $tzd);
echo date('c', $timestamp)
I want the last modified PHP/HTML file date (timestamp); if it was edited two days ago, it shows that date, etc.