How to Automatically Add the Current Year in PHP

Happy New Year. In this lesson we cover how to automatically add the current year to your copyright. Quite appropriate for today!

The magic of using a server-side language like PHP is that we can automate many processes.

At this time of year, I can imagine that many sites will have the incorrect year displayed in their copyright message, especially if they are standard HTML sites.

Using a simple line of PHP code we can automatically add the copyright year.

BEFORE

<div>
   &copy; 2015 Coding Academy
</div>

AFTER

<div>
   &copy; <?php echo date("Y") ?> Coding Academy
</div>

Want to Learn More?

Become a member and get access to the member only area of this site.

LEARN MORE

Comments

Your email address will not be published.

PHP for Beginners

Would you like lifetime access to the hugely successful PHP for Beginners course? Click here to find out how.

FREE Code Snippets

FREE hints and tips delivered direct to you once per month.