Only a few days left until we celebrate the new year. Champagne, parties, fireworks and yes, new years resolutions.
One thing that is on a lot of web professionals todo lists is to update their ‘Copyright’ notices. Or at least it should be.
A lot of websites take hours, days or even years to update. Google generally takes up to 48 hours to update all their footers but it is not unlikely to find “Copyright 2006″ on some websites even today.
So why not automate the whole thing like we did for our blog? A few lines of code are enough to just print the year there. As long as your server’s internal clock is on time you will always display the current year.
Since you are going into code anyway you might as well change that “2009″ to one of the dynamic code snippets below and you will be forever up-to-date:
PHP:
< ?php print date(“Y”); ?>
ASP:
< %response.write(“Current Year: “&Year(Date))%>
ASP.NET:
< %Response.Write(System.DateTime.Now.Year.ToString());%>
Javascript:
<script type=”text/javascript”>
<!–
var currentTime = new Date()
var year = currentTime.getFullYear()
document.write(year)
//–>
</script>
Any other code snippets that are useful?
Let me know in the comments so I can add them.















You forgot Ruby! :P
Simple yet good one.
Oh c’mon, you make JS look like a dinosaur, this one works too:
document.write(new Date().getFullYear())
You’ve got fancy ” on the JavaScript code, so copy and pasting it won’t work.
Copyright © 2009
PHP, displays things like Copyright (c) 2009-10, the difference being that it gives the first year as well as the most recent. For 2009 it only gives Copyright (c) 2009 though, for conciseness.
The best thing anyone can do is just remove the Copyright line from their webpage. It is not needed.
Why on earth do you have the Copyright 2006-2009 line on this blog? Any rationale behind it, other than 20 years ago yes it was needed?
JSP:
That was the full ruby snippet. But better yet: Time.now.year. To print to the screen, just prepend an equal sign to it.
Hmm.. code disappeared… Anyway: Date.today.year
Email me (boris@thenextweb.com) the complete snippet so I can include it here!