Current year with JavaScript getFullYear()

Did you hard code the year in your footer? New year, new problems. Get the current year in Javascript with the getFullYear() function.

Current year with JavaScript getFullYear()

With this one-liner, you can dynamically set the year with the JavaScript getFullYear() function:

let year = new Date().getFullYear();

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

<template>
    <footer>
        Copyright © {{ new Date().getFullYear() }}
    </footer>
</template>

Happy new years!


Building in public, sharing as I go →

You can find more details about my newsletter here.

PS: You can also follow on Twitter - @nickfrosty