Display Current Year Within Copyright Notice in PHP

- 1 minute read

Suppose you have a footer.php file that includes the following content:

<p>&copy; 2021</p>

Instead of manually updating the copyright notice every year, you could instead automatically display the current year by grabbing it from the built-in date function and echoing it into your HTML:

<p>&copy; <?php echo date('Y'); ?></p>

The exact time at which the year will update depends on the timezone of your site, which can be customized.

Link to this section Conclusion

This snippet also works to grab the current year in contexts other than copyright notices, but this is just one common use case.

I hope it helped you!