Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
setDate() は Date インスタンスのメソッドで、地方時に基づいてこの日時の月内の日を変更します。
月内の「日」を表す整数の値です。
その場で Date オブジェクトを変更し、新しいタイムスタンプを返します。 dateValue が NaN (または undefined など、 NaN に変換されるその他の値)の場合、日付は無効な日時に設定され、 NaN が返されます。
指定した数値が指定した範囲外の場合、Date オブジェクトの日付情報がそれに応じて更新されます。例えば、 Date オブジェクトが 6 月 1 日を保持している場合、 dateValue を 40 に変更すると日付は 7 月 10 日になり、 dateValue を 0 に変更すると日付は前月の最終日である 5 月 31 日になります。
| ECMAScript® 2027 Language Specification # sec-date.prototype.setdate |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年6月18日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.