document.lastModified help

D

dbahlmann

Hi,

I'm using document.lastModified function to return my document last
mod date. The function returns 1-Jan-1970. The problem seems to be
that the file name is index.php instead of index.html. I have some php
includes in the index files. When I change the php file to htm file
the lastModified function works correctly.

Any help?

Thanks
 
B

Bjoern Hoehrmann

* (e-mail address removed) wrote in comp.lang.javascript:
I'm using document.lastModified function to return my document last
mod date. The function returns 1-Jan-1970. The problem seems to be
that the file name is index.php instead of index.html. I have some php
includes in the index files. When I change the php file to htm file
the lastModified function works correctly.

The value of the attribute depends on the server telling the browser a
Last-Modified date in a Last-Modified header. For static files servers
will typically get the date from the file system, with dynamically ge-
nerated documents that is not an option, so programmers usually have to
set the date from their scripts.
 
J

Jeremy

Hi,

I'm using document.lastModified function to return my document last
mod date. The function returns 1-Jan-1970. The problem seems to be
that the file name is index.php instead of index.html. I have some php
includes in the index files. When I change the php file to htm file
the lastModified function works correctly.

Any help?

Thanks


Not really a Javascript issue, but try putting this at the very top of
your PHP document (MUST be before any whitespace or anything else, or it
won't work):

<?php header("Last-Modified: " . date('D, d M Y H:i:s T',
filemtime(__FILE__)); ?>

(You can also try getlastmod() instead of the filemtime() call, but
there are complaints about it failing under certain conditions).

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top