Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.