Automate your website copyright date

Now that the new year is here, many of us will forget to change the © copyright date on our many websites. I’ve never really been sure why developers don’t always automate this process and therefore not have to worry about it at the change of the year. In this short post I will show you some quick methods of automating this process.
PHP
If your pages are written in PHP, all you need to do is to add this simple line in the place that you want the date to appear:
<?php print date('Y'); ?>
JavaScript
You can also use this simple JavaScript code to generate the year:
<script type='text/javascript>document.write(new Date().getFullYear());</script>
.NET
The two methods for C# and VB are very similiar, but I’ve included both for completeness.
C#:
<%= DateTime.Now.Year.ToString(); =>
VB:
<%= DateTime.Now.Year.ToString =>
Python
In Python, all you have to do is import the datetime library and add the line:
print datetime.date.today().year
Of course there are other languages and methods of doing this, these are just a few. I will add more as I find them or if others suggest that I should.
If you have any other suggestions of ways to automatically output the year on a webpage, or have other languages to suggest, please do so.
Related posts:









[...] This post was mentioned on Twitter by Ian Devlin, Michael Davis. Michael Davis said: RT @iandevlin: New blog post: automate your website copyright date: http://bit.ly/5zW0bX #webdesign #webdevelopment [...]
[...] This post was Twitted by iandevlin [...]
Good ol’ autodate. Good man. Doesn’t get enough of a mention…
Updated for Python.
[...] I had made a blog post about that very thing! Automate your website copyright date web :: blog :: twitter Reply With Quote + Reply to Thread [...]
Nice! However, I found a bug. Your PHP example has an incorrect PHP closing tag. Should be ‘?>’.
I found this when I cut and paste the code for my site.
stv
Doh, thanks. Fixed!