Automatic Update The Footer Date Year

Display the current year – auto updating copyright footer

Inserting the current date or year in your website’s copyright footer message is too often overlooked by a lot of website owners.

Don’t let a small mistake make your company or blog look unprofessional. Accumulating small mistakes can have a negative effect on your customers’ perception of you or your business.

The following steps are for WordPress users, however if you haven’t got a WordPress website I’ll show you the steps you can use for any type of site.

Step 1 – Insert this code

Find your theme’s footer.php file in Appearance>Editor or go into your theme’s custom options to replace your copyright notice.

Add this text:

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

Hit update and you’re done.

If you were expecting more steps… well sorry to disappoint. :)

This will work with any PHP website, not just WordPress. You can even insert this code in widgets if you’ve enabled PHP code in widgets.

Top Tips

If you want to add the copyright symbol © in HTML. Add this:

&copy;

To place the year inside header tags or to insert HTML elements before and after the date add something like this:

<?php the_date('Y', '<h2>', '</h2>'); ?>

Alternative date formats – inserting the current time, day, month and/or year

Here are some examples of what is achievable using the date/time functions in WordPress.

  • F j, Y g:i a – April 29, 2014 12:50 am
  • F j, Y – April 29, 2014
  • F, Y – April, 2014
  • g:i a – 12:50 am
  • g:i:s a – 12:50:48 am
  • l, F jS, Y – Tuesday, April 29th, 2014
  • M j, Y @ G:i – Apr 29, 2014 @ 0:50
  • Y/m/d \a\t g:i A – 2014/04/29 at 12:50 AM
  • Y/m/d \a\t g:ia – 2014/04/29 at 12:50am
  • Y/m/d g:i:s A – 2014/04/29 12:50:48 AM

Commas and forward slashes are read literally. Using lowercase and capitals creates a different effect also.

Complete date/time examples for you to copy and paste

<?php the_date('l, jS F, Y'); ?>
<?php the_date('jS F, Y'); ?>
<?php the_date('F j, Y'); ?>
<?php the_date('Y'); ?>
<?php the_time('g:i:s a'); ?>

I hope you found this useful. If you also needed to display the current year in WordPress and have a good tip, please add a comment below.

Not got a WordPress site? – then you could use javascript instead

There are thousands of ways and variations to display the current year, date and/or time using javascript. Below are a couple of simple examples. Learn more about using javascript to insert times and dates.

<script type="text/javascript">
var currentDate =newDate()
var day = currentDate.getDate()
var month = currentDate.getMonth()+1
var year = currentDate.getFullYear()
  document.write(day +"/"+ month +"/"+ year)
</script>

or

<script type="text/javascript">
<!--
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}
document.write(hours + ":" + minutes + " ")
if(hours > 11){
document.write("PM")
} else {
document.write("AM")
}
//-->
</script>

Best,
The Zaposphere Team

Posted in Engineering Deck, Functionality, WordPressTagged , , , ,

Free WordPress tips for your inbox

Have our latest blog posts delivered straight to your inbox.

Comments 2

  1. Funny how you haven’t updated your site footer ;). Trying to figure this out for html emails but can’t seem to figure it out.

Ask a question or write a comment here…