Description
The setFullYear() method sets the year (four digits), according to local time.
This method has the form:
Date.setFullYear(year,month,day)
Parameter | Description |
---|---|
year | (required) A four-digit value representing the year |
month | (optional) An integer between 0 and 11 representing the month |
day | (optional) An integer between 1 and 31 representing the date |
Examples
The following example shows the basic use of this method.
<script>
var d = new Date();
d.setFullYear(2012);
document.write(d);
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|