Set UTC Full Year Method
The Set UTC Full Year method sets the UTC year of a date object to a four digit year that you specify in the year argument.
Format
dateVar.setUTCFullYear(year[, month[, date]])
The following table describes the arguments for the Set UTC Full Year method.
Argument | Description |
---|---|
year |
The UTC year to set in dateVar as a four digit integer. You must express the year in four digits. |
month |
As an option, you can use the month argument and the date argument to set the month and date of the year. For more information, see Values for Dates and Times. |
date |
Example
The following example does the following work:
To assign the date of the 2000 summer solstice, it uses the Set UTC Full Year method
To assign time to a date object, it uses the Set UTC Hours method
Determines the local date and displays it
This example uses the following code:
function dateBtn_Click ()
{
var Mstring = " A.M., Standard Time.";
var solstice2K = new Date;
solstice2K.setUTCFullYear(2000, 5, 21);
solstice2K.setUTCHours(01, 48);
var localDate = solstice2K.toLocaleString();
var pos = localDate.indexOf("2000")
var localDay = localDate.substring(0, pos - 10);
var localHr = solstice2K.getHours();
if (localHr > 11 )
{
localHr = (localHr - 12 );
Mstring = " P.M., Standard Time.";
}
var localMin = solstice2K.getMinutes();
var msg = "In your location, the solstice is on " + localDay +
", at " + localHr + ":" + localMin + Mstring;
TheApplication().RaiseErrorText(msg);
}
This example produces the following result:
In your location, the solstice is on Tue Jun 20, at 6:48 P.M., Standard Time.