Believemy logo purple

Automate the date of your footer

On 1 January, we often have other things to do than change the date in the footer of our sites... So let's use JavaScript or PHP to automate it!
Updated on December 9, 2024
Believemy logo

On January 1st, we often have other things to do than manually updating the footer date on our websites... So let's use JavaScript or PHP to automate it!

You can find the entire tutorial on our Instagram account

 

With PHP

If you want to automate the date in your footer, doing it with PHP is undoubtedly one of the simplest methods!

HTML
<footer>
    <p>
        © <?= date('Y'); ?> BELIEVEMY
    </p>
</footer>

 

With JavaScript

You can also use JavaScript to automate the date in your footer. The downside is that you'll have to do it with numerous lines of code, but the advantage is that you don't need to master PHP. So it's an interesting alternative.

HTML
<footer>
    <p>
        ©
        <span id="footer-year"></span>
        BELIEVEMY
    </p>
</footer>

And on the JavaScript side:

JAVASCRIPT
const footerYear = document.querySelector('#footer-year');

footerYear.innerHTML = new Date().getFullYear();
Category: Development
Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Try for Free

Whether you're scaling your startup, building your first website, or transitioning to a developer role, Believemy is your new home. Join us, grow, and let’s build your project together.

Believemy is with anyone