Nick Frostbutter
ArticlesCurrent year with JavaScript getFullYear()

Current year with JavaScript getFullYear()

Nick FrostbutterNick Frostbutter
Jan 01, 2022


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

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

Happy new years!