Display Last Modified Date of web page using Apache modules and Javascript/jQuery -


how last modified date of file using html dom lastmodified property. @ present, code have returns present date. reading other posts see because either:

a)the document indeed being modified on-load due js dom manipulation etc

and/or

b) need adjust apache server configs return information in header document.lastmodified can use display last-mod date instead of current date.

how use mod_expires or other module this? -or- can somehow use ssi directive:

<!--#flastmod virtual="$document_uri" --> 

to retrieve info , capture via javascript use somewhere else in page.

i not want have place in every location want show it, rather use in globally included footer or header , use javascript/jquery dynamically render last modified date in various other html elements.

here code using now, hope helps show how plan implement in in html:

$(function() { var x = new date(document.lastmodified); var frmt_options = {     weekday: "long",     year: "numeric",     month: "short",     day: "numeric",     hour: "2-digit",     minute: "2-digit" }; var xy = x.tolocaletimestring("en-us", frmt_options); $('h1.template').append("<span>last modified: " + xy + "</span>"); $('h2.main_category').append("<span>last modified:<br>" + xy + "</span>"); }); 

so tried , seems work. includes cross-browser friendly formatting date works in ie, ff, safari , chrome.( formatting solution in above answer breaks in ie , safari). put in global header:

<span class="lastmod"> file last modified  <!--#config timefmt="%b %e, %y - %i:%m%p" -->    <!--#echo var="last_modified" --> </span> 

js:

var lm= $('.lastmod').text()     $('h1.template').append(lm); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -