getDate() returns the day of the month for a JavaScript Date in local time. The result is an integer from 1 to 31.
const date = new Date("2026-09-10T12:00:00+05:30");
console.log(date.getDate()); // 10
Use getDate() for the date within the month. Do not confuse it with getDay(), which returns the weekday number.
const dayOfMonth = date.getDate();
There are no parameters. A valid Date returns 1–31; an invalid Date returns NaN.
const today = new Date();
const day = today.getDate();
console.log(day);
If you need an English ordinal such as 21st, handle 11, 12 and 13 before looking only at the last digit.
function ordinal(day) {
const mod100 = day % 100;
if (mod100 >= 11 && mod100 <= 13) return `${day}th`;
switch (day % 10) {
case 1: return `${day}st`;
case 2: return `${day}nd`;
case 3: return `${day}rd`;
default: return `${day}th`;
}
}
console.log(ordinal(21)); // 21st
const day = String(date.getDate()).padStart(2, "0");
This is useful when assembling a custom DD/MM/YYYY-style display.
const localDay = date.getDate();
const utcDay = date.getUTCDate();
Near midnight the local and UTC calendar dates can differ. Choose the method that matches the time basis of your application.
const bad = new Date("invalid");
console.log(bad.getDate()); // NaN
getDate() with getDay().Alert-window examples are available separately. getDay() Date Reference
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.