Future proof your footer's copyright date with the current year

Written on January 4, 2015
Updated on January 1, 2022

It’s a new year and one of the quickest ways for your site to seem dated is by not updating the copyright year in the footer.

To combat this, the easiest way is to have your site generate the current year for you.

Here are a few code snippets in a few select languages.

JavaScript

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

Ruby

<%= Time.now.year %>

PHP

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

Ember.js

// You'd most likely want to create a component to handle this. In the component's JS file, create a property like `currentYear`
...
currentYear: new Date().getFullYear(),
...
// Then in your component's handlebars file, reference the property like this.

<footer>&copy; 2014 - {{currentYear}}</footer>

Jekyll

Future proofing a Jekyll project’s copyright is a little more manual, but here are step by step instructions on future-proofing your Jekyll copyright date.

Liquid template

If your project is using the Liquid template language such as in a Shopify site or an Eleventy generated, static site – you can use now, a special Liquid word.


%copy; 2021-{{"now" | date: "%Y"}}

Stay in touch

Thanks for reading this article. I'd love to stay in touch and share more tips on programming and side projects with you. Sign up and I'll send you my articles straight to your email, you'll also get a free copy of the light themed version of my Git cheat sheet.
Git cheat sheet preview image