INFO: Date.getYear() Method Return Value ChangedID: Q183618
|
In JScript 3.0, the Date.getYear() method returns the full year for years after 1999.
In JScript 1.0, which is installed with Microsoft Internet Explorer 3.0,
the Date.getYear() method returns the current year minus 1900. So, the year
1999 returns 99 and the year 2000 returns 100.
In JScript 3.0, which is installed with Microsoft Internet Explorer 4.0,
the Date.getYear() method returns a two-digit value for years after 1900
and prior to 2000 and a four-digit value for years after 1999. So, the year
1999 returns 99 and the year 2000 returns 2000.
The following JScript demonstrates this behavior:
var d = new Date(2000, 1, 16)
alert("Date: " + d.getYear()); // returns 2000 in JScript 3.0
// returns 100 in JScript 1.0
This change was made to conform to ECMA 262, the standard on which JScript
is based.
function getFullYear(date)
{
fullyear = date.getYear();
if (fullyear < 1000) fullyear = fullyear + 1900;
return fullyear;
}
The above script works for all years after 1000.
For more information on the ECMA standard, refer to the following Web site:
http://www.ecma.ch/stand/ecma-262.htmFor information on using JScript, refer to the documentation available at the following Web site:
http://msdn.microsoft.com/scripting/
Additional query words:
Keywords : kb2000
Version : WINDOWS:1.0,2.0,3.0,4.0,4.01
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: July 14, 1999