JavaScript 1.3 Overview, Part I: Changes to the Date Methods - Doc JavaScript | WebReference

JavaScript 1.3 Overview, Part I: Changes to the Date Methods - Doc JavaScript


Changes to the Date Methods

JavaScript 1.3 adds optional parameters to a number of Date methods:


setMonth(<months>[, <date>])
setHourse(<hours>[, <minutes>[, <seconds>[, <milliseconds>]]])
setMinutes(<minutes>[, <seconds>[, <milliseconds>]])
setSeconds(<seconds>[, <milliseconds>])

These methods are similar to the equivalent setUTC* methods described in the previous page. The only difference is that the setUTC* methods set the date information according to the Universal Coordinate Time, while these methods set the date information according to local time. As with the setUTC* methods, if you do not specify these optional parameters, the appropriate get* methods are used: getDate(), getMinute(), getSeconds(), and getMilliseconds().

As explained in the previous page, if the number specified for any of the parameters is outside its expected range, the Date object is being updated accordingly. For example, if we set <date> to 45 for the month of June, then the month stored in the Date object is incremented to July, and <date> is set to 15.

https://www.internet.com


Created: September 14, 1998
Revised: September 14, 1998

URL: https://www.webreference.com/js/column25/datechg.html