Automatic Footer Copyright Update

Posted by: Alex on May 19, 2016

One of the most basic dynamic text areas on a website is the ubiquitous copyright year in a footer of a website.
Generally people use a basic PHP Date echo to output the current year:
PHP:

<?= date('Y'); ?>

However, with WordPress, it’s a bit harder to use PHP within certain themes, widgets and other kinds of builders as it often gets mutated or formatted as PHP can be potentially dangerous to write directly inside of WordPress.

This below code though is a very simple JavaScript snippet that will print the current year and will work with all text editors such as widgets and theme editors in WordPress etc.
JavaScript:

<script>document.write(new Date().getFullYear());</script>