Date.prototype.getDate()
getDate()
メソッドは、地方時に基づき、指定された日付の「日」を返します。
試してみましょう
構文
getDate()
返値
1 から 31 までの間の整数値。地方時に基づき、指定された日付の「日」を表します。
例
getDate() の使用
以下の 2 行目の文は、Date
オブジェクトである xmas95
の値に基づき、変数 day
に 25 という値を代入します。
const xmas95 = new Date('December 25, 1995 23:15:30');
const day = xmas95.getDate();
console.log(day); // 25
仕様書
Specification |
---|
ECMAScript Language Specification # sec-date.prototype.getdate |
ブラウザーの互換性
BCD tables only load in the browser