DEV Community

Cover image for JavaScript current year with getFullYear()
Nick Frostbutter
Nick Frostbutter

Posted on Originally published at frostbutter.com

JavaScript current year with getFullYear()

Did you hard code the year in your footer? New year, new problems.

With this one-liner, you can dynamically set the year with JavaScript:

let year = new Date().getFullYear();
Enter fullscreen mode Exit fullscreen mode

If you are using VueJS or NuxtJS, you can add the current year code directly into your template section

<template>
    <footer>
        Copyright © {{ new Date().getFullYear() }}
    </footer>
</template>
Enter fullscreen mode Exit fullscreen mode

You can find more useful dev articles on my site, frostbutter.com/articles

Top comments (0)