Name

getYear() — NN 2 IE J1 ECMA 1

Synopsis

Returns a number corresponding to the year but exhibits irregular behavior. In theory, the method should return the number of years the date object represents since 1900. This would produce a one- or two-digit value for all years between 1900 and 1999. However when you reach 2000, the pattern fails. Instead of producing values starting with 100, the getYear() method starting with Navigator 3 and IE 4, returns the same four-digit value as getFullYear(). For this reason, it is best to use getFullYear() whenever possible (but observe the browser compatibility for that method).

Returned Value

Integer between and 99 for the years 1900 to 1999; four-digit integer starting with 2000.

Parameters

None.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.