Skip to content

Instantly share code, notes, and snippets.

@kirandasika
Last active September 18, 2015 19:55
Show Gist options
  • Save kirandasika/80c54e898c46ff79fa45 to your computer and use it in GitHub Desktop.
Save kirandasika/80c54e898c46ff79fa45 to your computer and use it in GitHub Desktop.
Use getFullYear() instead of getYear() to get the 4 digit year value from the date object #JavaScript

getYear() is deprecated and is replaced by getFullYear()

getYear() is working for IE8, but it is broken for IE10.

For the Date object created by new Date("10/10/2013"), when you use getYear() IE8 returns 2013, but IE10 returns 113.

Inorder to get the 4-digit year value, you need to use the getFullYear() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment