WebDevelop/JavaScript2008. 8. 5. 10:53
The getYear() method returns the year, as a two-digit OR a three/four-digit number.
The value returned by getYear() is not always four digits. For years between 1900 and 1999 the getYear() method returns only two digits.
For other years (before 1900 and after 1999) the return is browsers dependant:
Internet Explorer:
Firefox:
dateObject.getYear() |
Note: This method is always used in conjunction with a Date object.
Important: The getYear() method should no longer be used. Use the getFullYear() method instead!!
설명을 간단히 하자면 getYear() 메소드 보다는 getFullYear() 메소드를 쓰는것이 좋다는 이야기다.
getYear() 메소드로는 브라우저에 따라.. 그리고 1900~1999 , 1900년 이전, 1999년 이후 에 따라서
리턴값이 많이 틀려지기 때문에 프로그램 만들경우 많은 고려가 필요하다.
특히나 firefox에서 테스트 하기를 좋아하는 나로서는 getYear() 메소드로 인해서 날짜값을 항상 이상하게
받아와 애를 먹은 경우가 있었다.