Availability: |
| ||||||
Property/method value type: | Time value | ||||||
JavaScript syntax: | - | myDate.setFullYear(aYearValue) | |||||
- | myDate.setFullYear(aYearValue, aMonthValue) | ||||||
- | myDate.setFullYear(aYearValue, aMonthValue, aDateValue) | ||||||
Argument list: | aDateValue | An optional date within the month value | |||||
aMonthValue | An optional 0 to 11 month value | ||||||
aYearValue | A full year value |
The result returned by this method will be the new time value of the containing object, having been adjusted by the values passed in as arguments.
The computations are carried out in local time coordinates.
ECMA mandates that the month and date should be optional arguments. If the date value is omitted, the value is provided internally as if the getDate() method had been invoked to provide it. Likewise the month value will be replaced by internally calling the getMonth() method.
<HTML> <HEAD> </HEAD> <BODY> <SCRIPT> myArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); myDate = new Date(); myDate.setFullYear(myDate.getFullYear() - 1); document.write("A year ago on today's date, it was a " + myArray[myDate.getDay()]); </SCRIPT> </BODY> </HTML>
Prev | Home | Next |
Date.setDate() | Up | Date.setHours() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |