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:

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!