Advice - Web Design

How to make your website copyright year automatically update

Hey everyone

If you’re a website designer then you’ve probably had that annoying issue of a new year coming and you then having to go into your website’s ‘copyright footer’ section and update the year. Well no longer my friend!

Today’s blog is very short since I’m just going to show you a very simply a piece of javascript code which you can copy and paste into your website’s copyright field in order for you to never have to update the year ever again.

So without further adieu here it is:

<script language=”javascript” type=”text/javascript”>
var today = new Date()
var year = today.getFullYear()
document.write(year)
</script>

That’s it! If you want to see this ‘in action’ then the code for our Aether Digital copyright footer is:

© Copyright <script language=”javascript” type=”text/javascript”>
var today = new Date()
var year = today.getFullYear()
document.write(year)
</script> by Aether Digital | All Rights Reserved

So you simply just paste that piece of code after the ‘Copyright’ wording and voila, your site will automatically have the correct year in your copyright info.

It’s nothing major but I know a lot of people out there who like attention to detail get annoyed having to update the year every 1st of January and so I thought this may help!

UPDATE

I have just been told by a fellow web designer that they had to tweak the code slightly in order for it to work on their WordPress theme, so if yours also doesn’t seem to work with the above code then also try this:

<script type=”text/javascript”> document.write(new Date().getFullYear()); </script>

Related Posts

Leave Your Comment

Your Comment*

Your Name*
Your Webpage