Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Date.prototype.getDate: local day of month

getDate returns the day of the month from 1 through 31, computed in the environment’s local time zone.

Version: ECMAScript 1 onward; example target: Node.js 24.22.2

Syntax

date.getDate()

date.getDate() returns the local day of the month as a Number from 1 through 31. It is not the day of the week; getDay() provides that. The result depends on the environment’s local time zone, so the same timestamp can have a different date after code moves. Use getUTCDate() for UTC calculations.

The method takes no arguments and does not mutate the date; extra arguments are ignored. For an invalid Date whose time value is NaN, it returns NaN. Calling it with a receiver that lacks Date internal state, such as Date.prototype.getDate.call({}), throws TypeError.

In practice, use it to display a local calendar day or as input to setDate, which normalizes out-of-range values across adjacent months. The method has existed since ECMAScript 1.

Examples

const date = new Date(2024, 1, 29, 12);
console.log(date.getDate());

date.setDate(date.getDate() + 1);
console.log(date.getDate(), date.getMonth());
console.log(Number.isNaN(new Date(NaN).getDate()));

Result

29
1 2
true

Sources