by Arun Sinha

Updating the copyright year on your website may not be a legal requirement, but it's smart marketing. It tells the visitor the site is current. Showing the copyright year is especially important if you have a site without dates on its content.

You can automatically refresh the copyright year by inserting a simple JavaScript or php script (see below) into your website's html code.

Entering either script won't change the copyright year in the Design view of your html editor. To see the results of entering your script, upload the edited web page to your web server, then go to your browser and reload the page.

Here's the JavaScript. Copy and paste it wherever you want the current year to appear:

<script type="text/javascript">
var today = new Date()
var year = today.getFullYear()

And here's the php script:

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

Yes, the php script is simpler, but it may not work just yet. You first need to take another step to make the php script run on html pages.

You need to create or edit an .htaccess file.

This is not as burdensome as it sounds. It's actually a good thing, because then you'll be able to run other php scripts on your site, which can be extremely useful.

If you're using WordPress, you don't need to edit the .htaccess file. You can skip straight to the Copyright That Spans Several Years section below.

Creating the .htaccess File

To set up an .htaccess file, open a new file in a text editor like Notepad or SimpleText.

Paste the following code into the file:

AddType application/x-httpd-php .htm .html

If you have an existing .htaccess file, open it and add the above code.

Alternatively, search your web host's site for "How to parse php within html files." Follow its instructions on what code to enter in the .htaccess file. (Your web host might specify a different process for parsing php in html pages. Follow those directions instead of the ones here.)

After inserting the code, in Notepad click File > Save As...

Type .htaccess as the file name and from the Save as type dropdown menu, select All Files.

Click Save, then go back and make sure the editor didn't add an extension to the filename after .htaccess. If you find an extension, delete it.

Upload the .htaccess file to the root directory of your website. This is the topmost folder of your website's file structure and contains your index file.

The .htaccess file now affects every other file in your website.

Updating Your Blog's Copyright Year

Depending on the blogging platform you're using, you may not have access to the .htaccess file.

In that case, use the JavaScript code.

Copyright That Spans Several Years

A range of years next to your copyright symbol subtly reminds the visitor how long you've been in business or how long your website has been up. Use the script to update the last year of your range.

Copy and paste the following as your copyright notice's html code. Change 2002 to the year in which your site was established:

Copyright &copy; 2002&ndash;

Then enter the JavaScript or php script for the current year immediately next to the semicolon..

Your copyright year updates are now on autopilot. One less thing to worry about at 12:00:01 a.m. next Jan. 1.

We design and build custom mobile websites. For details, contact us.

# # #


Google Ads and Search Engine Optimization