getFullYear (JavaScript)
Gets the year in local time.
Defined in
Date (Standard - JavaScript)Syntax
getFullYear() : int
Return value | Description |
---|---|
int |
The year. This method returns the full year,
for example, 1999 not 99 . |
Examples
This computed label adds one year to the current date. One day is first subtracted if the date is February 29 (leap year) so it appears as February 28 instead of March 1 in the next year.// Next year same time
var date = new Date();
if(date.getMonth() == 1) // if Feb
if(date.getDate() > 28) // if Feb 29
date.setDate(date.getDate() - 1);
date.setFullYear(date.getFullYear() + 1);
date.toString()