Automatic Copyright Year in WordPress Footer Text

Automatic Copyright Year in WordPress Footer Text

Copyright yearThis is just a very quick blurb regarding something simple that I had trouble with. The plan was to set the copyright year within the footer so that when the new year comes up, my site will automatically reflect the change. Anyone with even the most basic knowledge of PHP (like myself) knows about the PHP date function that allows you to display the date anywhere you like and in any format you like.

Copyright Year

In order to do just the year for the footer, I naturally used this code to show just the year: < ?php the_time('Y') ?>, which simply shows the full year. For the whole year, I felt I had everything set. When December 31st came around, I was out celebrating the new year and decided to check in with my website before and after midnight just to make sure the year would change. Fortunately I checked in within 8 hours of midnight because I noticed that at around 6pm, my sites were already showing 2015 when it should have been 2014 for another 6 hours.

Because I’m a stickler for accuracy, I needed to fix this! Before I had my first drink at the party, I had already realized what the problem was and set out to resolve it. As it turns out, the standard PHP date functions only show the year based on GMT time so since I’m located 8 hours behind GMT, my site was showing the wrong year for at least 8 hours.

Anyway, the proper function to take into account the world’s timezones is < ?php echo date_i18n('Y'); ?> . So now you have to find a way to get it in your footer. The problem is that not all WordPress themes are alike. You may not be able to enter direct PHP code or if your theme uses widgets for footer sections, you may need to install a special plugin just to allow code to be entered. The plugin I use is called Enhanced Text Widget. Just install that and you’ll find it available as a widget.

logo

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.