Date.prototype.getDate()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Die getDate()-Methode von Date-Instanzen gibt den Tag des Monats für dieses Datum gemäß der lokalen Zeit zurück.

Probieren Sie es aus

const birthday = new Date("August 19, 1975 23:15:30");
const date1 = birthday.getDate();

console.log(date1);
// Expected output: 19

Syntax

js
getDate()

Parameter

Keine.

Rückgabewert

Eine Ganzzahl, zwischen 1 und 31, die den Tag des Monats für das angegebene Datum gemäß der lokalen Zeit darstellt. Gibt NaN zurück, wenn das Datum ungültig ist.

Beispiele

Verwendung von getDate()

Die Variable day hat den Wert 25, basierend auf dem Wert des Date-Objekts xmas95.

js
const xmas95 = new Date("1995-12-25T23:15:30");
const day = xmas95.getDate();

console.log(day); // 25

Spezifikationen

Specification
ECMAScript® 2025 Language Specification
# sec-date.prototype.getdate

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
getDate

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch