JavaScript mendapatkan tahun ini
var currentYear= new Date().getFullYear();
Grepper
var currentYear= new Date().getFullYear();
new Date().getFullYear(); // This will get you the current year
document.write(new Date().getFullYear());
// create a Date var type then use getFullYear.
this.dob = new Date(dob);
this.getBirthYear = function() {
return this.dob.getFullYear();
}
const d = new Date();
d.setFullYear(2020);