homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Automatic Revision Dates with JavaScript
How to change the 'Last Updated' automatically?

 11:11 am on Sep 27, 2001 (gmt 0)

I would like to change the date of 'Last Updated' on my web site automatically. With the JavaScript command "document.lastModified", I get something like
Last Updated: 09/27/2001 13:00:35
But I would only like to have the date, and not the hours:
Last Updated: 27/09/2001
or even better:
Last Updated: September 27, 2001
Which JavaScript command should I introduce?
Thank You



 1:16 pm on Sep 27, 2001 (gmt 0)

Hi tommydc, and welcome to the forums at Webmaster World,

Here's a link to a page with one method: [chami.com...]


 9:44 pm on Sep 27, 2001 (gmt 0)

It would seem like the alternative would be to write something simple like this:

var sDate = document.lastModified();
document.write("Last updated on: " + sDate.substring(0,10));


 2:38 pm on Sep 28, 2001 (gmt 0)

var sSep = "/"
dModDate = new Date(document.lastModified);
dModDate = dModDate.getDate() + sSep + dModDate.getMonth() + sSep + dModDate.getYear()
document.write (dModDate);

You can change the separator by modifying the string sSep and swap the month and date to get US formatted dates.


 5:03 pm on Sep 28, 2001 (gmt 0)

I assume displaying the last modified date is for users only. Since most search engine spiders ignore JavaScript would they not miss this entirely?


 10:32 pm on Sep 28, 2001 (gmt 0)

I believe you are correct, spiders will probably not pick up the JS code.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved