Jump to content

[SOLVED] Header Last Modified Time


sKunKbad

Recommended Posts

For some reason, when you view the http header info for my .php pages, it does not show a last modified date and time. So, thinking that I could create one, I tried this:

 

<?php header("Last-Modified: ".filectime($_SERVER['PHP_SELF']); ?>

 

but it doesn't work. Does anyone know how to do what I am trying to do?

Link to comment
https://forums.phpfreaks.com/topic/56055-solved-header-last-modified-time/
Share on other sites

OK, this works:

 

<?php header("Last-Modified: " . date ("D, j M Y ", getlastmod()) . (date ("H", getlastmod())+4) . date (":i:s", getlastmod()) . " GMT");?>

 

but the problem is that if the lastmod was during certain hours, the output for the hour might show something like 24 or 26. Since there is no 24 or 26th hour in a day, I need to come up with something that keeps the date right, but I am stuck and need help.

 

Please help!

This is getting better, but I just want to know if there is an easier way:

 

$hours = date ("H", getlastmod())+4;
$daynumber = date ("j", getlastmod());
if ($hours == 24){
        $hours = 00;
        $daynumber = $daynumber + 1;
}
if ($hours >= 25){
$hours = $hours -24;
$daynumber = $daynumber + 1;
}
header("Last-Modified: " . date ("D, ", getlastmod()) . $daynumber . date(" M Y ", getlastmod()) . "$hours" . date (":i:s", getlastmod()) . " GMT");

 

Hasn't anyone ever done anything like this before?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.