HighDots Forums  

document.lastModified help

Javascript JavaScript language (comp.lang.javascript)


Discuss document.lastModified help in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dbahlmann@gmail.com
 
Posts: n/a

Default document.lastModified help - 06-02-2008 , 11:08 AM






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

Reply With Quote
  #2  
Old   
Bjoern Hoehrmann
 
Posts: n/a

Default Re: document.lastModified help - 06-02-2008 , 01:07 PM






* dbahlmann (AT) gmail (DOT) com wrote in comp.lang.javascript:
Quote:
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.
--
Björn Höhrmann · mailto:bjoern (AT) hoehrmann (DOT) de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/


Reply With Quote
  #3  
Old   
Jeremy
 
Posts: n/a

Default Re: document.lastModified help - 06-02-2008 , 04:07 PM



dbahlmann (AT) gmail (DOT) com wrote:
Quote:
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.