The new year is firmly upon us and now is a good time to update the copyright date year in your websites’ footer area. There are a variety of ways to do this depending on your programming language preference.

The PHP way

Before you jump in and use this method, be aware that it takes the current year from the server your website is hosted on (server side). So if you use US based web hosting, say in New York, for 5 hours at the beginning of the new year your website will have last years date printed. You can set the timezone PHP uses for scripts by setting this in a php.ini (or .user.ini)

<?php echo date( 'Y' ); ?>

More info on PHP date can be found in the PHP manual

The javascript way

This method will print the current year that the user visiting your website has set in their settings (client side).

<script>document.write(new Date().getFullYear())</script>

More info on the javascript date functions

If you are using a premium WordPress theme it may already do this for you, or at least have an options panel where you can set the date manually. I prefer to use the PHP method above for my clients’ websites as they are all hosted on my reliable UK based web hosting