Nick Frostbutter

ArticlesCurrent year with JavaScript getFullYear()

Current year with JavaScript getFullYear()

Nick FrostbutterNick Frostbutter
Jan 01, 2022

javascriptvuenuxtsnippets

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

1let 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

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

Happy new years!