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 here.

Comments

Your email address will not be published.

PHP for Beginners

Enrol in the full course here

PHP, MySQL and PDO

Coming soon, a full course on using PHP, MySQL and PDO. Be notified as soon as the course goes live.