xxxxxxxxxx
const currentYear = todaysDate.getFullYear()
xxxxxxxxxx
var currentYear= new Date().getFullYear();
// should use moment library
https://momentjs.com/
xxxxxxxxxx
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
console.log(currentYear);
xxxxxxxxxx
const year = new Date().getFullYear();
console.log(year); // Printing the current year to the console
xxxxxxxxxx
const date = new Date(); // Assuming the user wants to get the year from the current date
const year = date.getFullYear();
console.log(year); // Output: Current year (e.g., 2022)