JavaScript 1.3 Overview, Part I: UCT-Based Get Methods - Doc JavaScript | WebReference

JavaScript 1.3 Overview, Part I: UCT-Based Get Methods - Doc JavaScript


UCT-Based Get Methods

JavaScript 1.3 supports Universal Coordinate Time. There are two groups of the Date object's methods. The first ones include methods to get UCT's components of time (year, month, date, day, hour, minute, second, millisecond) from a given Date object. The other group includes methods to set these components in a given Date object. The following table summarizes the Get Methods:

MethodgetUTCFullYear()
ParametersNone
DescriptionReturns the year of the specified date according to the Universal Coordinated Time. The return value is an absolute number, 1998 for example.
Examplevar myBirthYear;
myBirthDate = new Date();
myBirthYear = myBirthDate.getUTCFullYear();
JavaScript 1.2getYear()

MethodgetUTCMonth()
ParametersNone
DescriptionReturns the month of the specified date according to the Universal Coordinated Time. The return value is an integer between 0 (January) and 11 (December).
Examplevar myBirthMonth;
myBirthDate = new Date();
myBirthMonth = myBirthDate.getUTCMonth();
JavaScript 1.2getMonth()

MethodgetUTCDate()
ParametersNone
DescriptionReturns the day of the month of the specified date according to the Universal Coordinated Time. The return value is an integer between 1 and 31.
Examplevar myBirthDayM;
myBirthDate = new Date();
myBirthDayM = myBirthDate.getUTCDate();
JavaScript 1.2getDate()

MethodgetUTCDay()
ParametersNone
DescriptionReturns the day of the week of the specified date according to the Universal Coordinated Time. The return value is an integer between 0 (Sunday) and 6 (Saturday).
Examplevar myBirthDayW;
myBirthDate = new Date();
myBirthDayW = myBirthDate.getUTCDay();
JavaScript 1.2getDay()

MethodgetUTCHours()
ParametersNone
DescriptionReturns the hour of the day of the specified date according to the Universal Coordinated Time. The return value is an integer between 0 and 23.
Examplevar myBirthHour;
myBirthDate = new Date();
myBirthHour = myBirthDate.getUTCHours();
JavaScript 1.2getHours()

MethodgetUTCMinutes()
ParametersNone
DescriptionReturns the minutes of the hour of the specified date according to the Universal Coordinated Time. The return value is an integer between 0 and 59.
Examplevar myBirthMinute;
myBirthDate = new Date();
myBirthMinute = myBirthDate.getUTCMinutes();
JavaScript 1.2getMinutes()

MethodgetUTCSeconds()
ParametersNone
DescriptionReturns the seconds of the minute of the specified date according to the Universal Coordinated Time. The return value is an integer between 0 and 59.
Examplevar myBirthSecond;
myBirthDate = new Date();
myBirthSecond = myBirthDate.getUTCSeconds();
JavaScript 1.2getSeconds()

MethodgetUTCMilliseconds()
ParametersNone
DescriptionReturns the milliseconds of the second of the specified date according to the Universal Coordinated Time. The return value is an integer between 0 and 999.
Examplevar myBirthMS;
myBirthDate = new Date();
myBirthMS = myBirthDate.getUTCMilliseconds();
JavaScript 1.2None

http://www.internet.com


Created: September 11, 1998
Revised: September 11, 1998

URL: http://www.webreference.com/js/column25/dateget.html