Date.setMonth()

JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, NES2+, IE 3+, Opera3+ Syntax

							date.setMonth(month)

Description

The setMonth() method sets the month in the Date object to the argument month, an integer from 0 (January) to 11 (December). The method returns an integer representing the number of milliseconds between midnight January 1, 1970 (GMT) to the date and time specified in the Date object after the month has been adjusted.

Caution

Prior to JavaScript 1.2, this method returned nothing.

Example

The code in Listing 6.97 displays the current date in milliseconds before setting the month to 2 (March). Notice that the milliseconds specified after the setMonth() method are the same as the result returned from the method. ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.