Forum Moderators: open

Message Too Old, No Replies

Script Help

dynamic date copyright info script

         

CNibbana

1:39 am on Nov 3, 2003 (gmt 0)

10+ Year Member



I've been trying to think of a better way to update the copyright footer at the bottom of my site other than changing the year on every page and re-uploading the entire site when 2004 rolls around.

I decided using Javascript and a call date function would work best, but I can't get it to work. This is what I have:

In the html page where I want the footer:
<script language="javascript" type="text/javascript" src="scripts/footer.js"></script>

In the footer.js page:
year=getYear();
document.write("Copyright &copy;" + year + "All Rights Reserved");

Can someone please help? Thanks.

korkus2000

2:30 am on Nov 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the board,

Try something like this:

var d = new Date();
document.write("Copyright &copy; " + d.getFullYear() + " All Rights Reserved");

You must instantiate the date object to use its methods. getFullYear gives you 4 digit year instead of the 2 digit getYear method.

Here is somemore info on it:
[w3schools.com...]

CNibbana

12:57 pm on Nov 3, 2003 (gmt 0)

10+ Year Member



Works great. Thanks!