Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 1, 2022 02:27 pm GMT

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();

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>

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


Original Link: https://dev.to/nickfrosty/javascript-current-year-with-getfullyear-h1c

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To