getDate メソッド
メソッド getDate は
日付オブジェクト
に適用され、現在の月の日の番号を返します。
日の番号付けは 1 から始まります。
構文
日付.getDate();
例
現在の日の番号を出力してみましょう:
let date = new Date();
let res = date.getDate();
console.log(res);
例
指定された日付の日を出力してみましょう:
let date = new Date(2025, 11, 31);
let res = date.getDate();
console.log(res);
コード実行結果:
31
関連項目
-
メソッド
getDay,
曜日を取得する -
メソッド
getFullYear,
年を取得する -
メソッド
getMonth,
月を取得する -
メソッド
getDate,
月の日を取得する -
メソッド
getHours,
時間を取得する -
メソッド
getMinutes,
分を取得する -
メソッド
getSeconds,
秒を取得する -
メソッド
getMilliseconds,
ミリ秒を取得する