Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

How can I get an automatic "last updated" in my web page?


(!)

Podman's Avatar
Podman Podman is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: Mar 2008
Experience: Beginner
16-Mar-2008, 01:02 PM #1
Question How can I get an automatic "last updated" in my web page?
I haev been designing a web page for my wife. I am far from a web designer but have been quite chuffed with the results so far. She has just asked if it would be possible for me to add into the bottom of the page a "Last updated" section so people know the site is contstantly being updated.

The site is css style sheet with normal HTML pages. Could anybody tell me what code I would need to enter into the html of each page to get a "Last updated" section please.

Any help would be greatly appreciated.

Thanks
Pod.

Last edited by Podman; 16-Mar-2008 at 01:04 PM.. Reason: Can't spell!
Sequal7's Avatar
Computer Specs
Senior Member with 2,382 posts.
 
Join Date: Apr 2001
Location: Around the corner!
Experience: Including today?
16-Mar-2008, 02:16 PM #2
You can use javascript, place this where you want the text to display (NOTE: If you are using a webpage editing program like frontpage, dreamweaver or similar you will need to be in source or code view for inserting this to work)
Code:
<script type="text/javascript">

<!--
var m = "This page was last updated: " + document.lastModified;
var p = m.length-8;
document.writeln("<center>");
document.write(m.substring(p, 0));
document.writeln("</center>");
 -->
</script>
You can chane the text displayed by changing "This page was last updated: " to your own statement and you can change document.writeln("<center>"); to document.writeln("<left>"); or document.writeln("<right>");. Just make sure to change the closing document.writeln("</center>"); to the same /left or /right as the first alignment properties

Or, you could use built in code (insert > date > automatically update) in frontpage or dreamweaver etc so that when you re-open the page, it updates that field automatically.

Last edited by Sequal7; 17-Mar-2008 at 12:11 AM.. Reason: Bolded
Podman's Avatar
Podman Podman is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: Mar 2008
Experience: Beginner
16-Mar-2008, 02:22 PM #3
Brilliant! Thanks very much, I am using Kompozer, I do have dreamweaver and frontpage but Kompozer seemed the easiest to get straight into using.
Sequal7's Avatar
Computer Specs
Senior Member with 2,382 posts.
 
Join Date: Apr 2001
Location: Around the corner!
Experience: Including today?
16-Mar-2008, 02:36 PM #4
Komposer is very good and very easy to use, unfortunately it does not have an insert/auto date function so you would need to use the code I gave you in the previous post. (this can also be accomplished with PHP, ASP, PERL etc..)

NOTE: You can click the area you want the date to show on the page in html view, then click the code view and your mouse will be in the correct place, paste that code and it will show once you view the webpage.
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,625 posts.
 
Join Date: Oct 2006
16-Mar-2008, 04:01 PM #5
the script tag should look like <script type="text/javascript">

also it is preferable to use the dom to insert content into the page, not document.write.

in the head:
PHP Code:
<script type="text/javascript">
onload = function(){
    
document.getElementById("lastModified").innerHTML "Page last changed " document.lastModified.split(" ")[0];
}
</script> 
later on in the body:

HTML Code:
<span id="lastModified"></span>
good read: http://www.quirksmode.org/js/lastmod.html

Last edited by MMJ; 16-Mar-2008 at 04:11 PM..
Podman's Avatar
Podman Podman is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: Mar 2008
Experience: Beginner
16-Mar-2008, 04:25 PM #6
I am in the uk, how can I get it to show as dd/mm/yyyy rather than mm/dd/yyyy ?
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,625 posts.
 
Join Date: Oct 2006
17-Mar-2008, 06:26 AM #7
PHP Code:
<script type="text/javascript">
var 
pcs document.lastModified.split(" ")[0].split("/");
var 
date pcs[1] + '/' pcs[0] + '/' pcs[2];
onload = function(){
    
document.getElementById("lastModified").innerHTML "Page last changed " date;
}
</script> 
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2