javascript date to year code example Example: JS date year var d = new Date(); var n = d.getFullYear();