The year number for the receiving object normalized to UTC time coordinates. The result is a full 4 digit year number value based on the UTC time value.
If you are computing relative times or developing scripts that operate on very early dates, Netscape will not support negative year numbers, and cannot go any earlier than year zero. MSIE can, if necessary return a negative year number.
<HTML> <HEAD></HEAD> <BODY> <SCRIPT> // Calculate which century from the year number myDate = new Date(); myCentury = 1 + myDate.getUTCFullYear()/100; switch (myCentury % 10) { case 1 : mySuffix = "st"; break; case 2 : mySuffix = "nd"; break; case 3 : mySuffix = "rd"; break; default : mySuffix = "th"; break; } document.write(myCentury + mySuffix + " century"); </SCRIPT> </BODY> </HTML>
See also: | Date.prototype, Date.setUTCFullYear() |
Prev | Home | Next |
Date.getUTCDay() | Up | Date.getUTCHours() |
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. |