Last updated on Jul 6, 2022 by Suraj Sharma
In this tutorial, you will learn to get the current year using the JavaScript's Date
object.
To get the current year in JavaScript, we will use the getFullYear()
method available in the Date
object. It returns the year in ‘YYYY’
format.
const date = new Date()
currentYear = date.getFullYear()
console.log(currentYear) // "2022"
Related Solutions
Rate this post
Suraj Sharma is the founder of Future Gen AI Services. He holds a B.Tech degree in Computer Science & Engineering from NIT Rourkela.