If you want to extract the year from Date in Javascript, try getFullYear() method instead of getYear(), see the output below on Firefox and Chrome:
Here’s the code:
<html> <head> <script langauge="javascript"> var date1 = new Date(); var browser = navigator.userAgent; var dateMessage = "I am on "+browser+"nnCurrent Date : "+ date1; dateMessage += "ndate1.getYear()>> "+date1.getYear()+ "ndate1.getFullYear()>> "+date1.getFullYear(); alert(dateMessage); </script> </head> </html>