Pet peeve: Wrong year in the footer

One of the simplest things that most folks do incorrectly when creating a website is hardcode the copyright year in the footer. Ugh.

It’s a little thing, but it shows how attentive the developers or designers are to the little details. Can they write code that will stand the test of time? Do they think of all of the edge cases? Or are they more shortsighted with their coding approach? It is January 2018, you can easily surf around to your favorite sites and see which ones were lazy—their sites say “© 2017.”

Pst! It should auto-magically say”© 2018.” That’s the beauty of writing code. It should automatically work.

It’s a pet peeve of mine, so let me show you how best to do it in a few languages.

Output the current year in PHP

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

Output the current year in Rails

<%= Time.current.to_date.end_of_month.strftime('%Y '); %>

Output the current year in Javascript

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

Happy new year (for many years to come)!

Photo by Freddy Marschall on Unsplash