setDate Method (Date) (JavaScript)

Sets the numeric day-of-the-month value of the Date object using local time.




Required. Any Date object.

Required. A numeric value equal to the day of the month.


To set the day-of-the-month value using Universal Coordinated Time (UTC), use the setUTCDate method.

If the value of numDate is greater than the number of days in the month, the date rolls over to a later month and/or year. For example, if the stored date is January 5, 1996 and setDate(32) is called, the date changes to February 1, 1996. If numDate is a negative number, the date rolls back to an earlier month and/or year. For example, if the stored date is January 5, 1996 and setDate(-32) is called, the date changes to November 29, 1995.

The setFullYear Method (Date) can be used to set the year, month, and day of the month.


The following example shows how to use the setDate method.

var date = new Date("12/15/1990");  

// Output (for the PST time zone): Sun Dec 30 00:00:00 PST 1990  


Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Applies To: Date Object

See Also

getDate Method (Date)
setFullYear Method (Date)
setMonth Method (Date)
setUTCDate Method (Date)