Make Your Copyright Year Automatically Update

Autoupdating Copyright Year

At the time of writing, the year 2013 is quickly approaching. Many of us bloggers and website owners have a copyright date in our footer, and this is something that most of us update every year after New Years. Thankfully, there’s a way to update this automatically with a little snippet of PHP.

For WordPress users, this is quite simple. Simply replace your copyright year with this code:

<?php the_date('Y'); ?>

For all other website owners (provided you are running a PHP website), use this code:

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

Those of you running HTML sites are going to have to go a little old school with some Javascript:

<script type="text/javascript">
var theDate=new Date()

Merry Christmas, and Happy New Year!

What People Are Saying:

  1. James Graham says:

    A great fundamental for all dynamic PHP and Javascript websites, be it on WordPress or your own PHP site.

  2. Billy says:

    Not sure why the js doesn’t work on some of my sites, even with CloudFlare in dev mode. Some sites that are CloudFlare assisted render the year fine. *Sigh.*

Leave a Reply

Copyright 2024, All rights reserved. Yadda yadda.