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.
Get the TNW newsletter
Get the most important tech news in your inbox each week.