Core JavaScript 1.5 Reference:Global Objects:Date:getFullYear
From MDC
(Redirected from Core JavaScript 1.5 Reference:Objects:Date:getFullYear)
Contents |
[edit] Summary
Returns the year of the specified date according to local time.
| Method of Date | |
| Implemented in: | JavaScript 1.3 |
| ECMA Version: | ECMA-262 |
[edit] Syntax
getFullYear()
[edit] Parameters
None.
[edit] Description
The value returned by getFullYear is an absolute number. For dates between the years 1000 and 9999, getFullYear returns a four-digit number, for example, 1995. Use this function to make sure a year is compliant with years after 2000.
Use this method instead of the getYear method.
[edit] Examples
[edit] Example: Using getFullYear
The following example assigns the four-digit value of the current year to the variable yr.
var today = new Date(); var yr = today.getFullYear();