--- title: Date.prototype.getDay() slug: Web/JavaScript/Reference/Global_Objects/Date/getDay tags: - Date - JavaScript - Method - Prototype - Reference - getDay - メソッド translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay --- <div>{{JSRef}}</div> <p><span class="seoSummary"><strong><code>getDay()</code></strong> メソッドは、地方時に基づき、指定された日付の「曜日」を返します。 0 は日曜日を表します。</span>「日」を取得する方法は {{jsxref("Date.prototype.getDate()")}} をご覧ください。</p> <div>{{EmbedInteractiveExample("pages/js/date-getday.html", "shorter")}}</div> <div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="syntaxbox notranslate"><var>dateObj</var>.getDay()</pre> <h3 id="Return_value" name="Return_value">返値</h3> <p>整数値で、 0 から 6 までの値を取り、地方時に基づいて指定された日付の曜日に対応し、 0 は日曜日、 1 は月曜日、 2 は火曜日のようになります。</p> <h2 id="Examples" name="Examples">例</h2> <h3 id="Using_getDay" name="Using_getDay">getDay の使用</h3> <p>以下の 2 行目の文は、{{jsxref("Date")}} オブジェクト <code>Xmas95</code> の値に基づき、<code>weekday</code> に 1 という値を代入します。1995 年 12 月 25 日は月曜日です。</p> <pre class="brush: js notranslate">var Xmas95 = new Date('December 25, 1995 23:15:30'); var weekday = Xmas95.getDay(); console.log(weekday); // 1 </pre> <div class="blockIndicator note"> <p><strong>注:</strong> 必要であれば、曜日の完全な名前 (例えば "<code>Monday</code>") は {{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}} に <code>options</code> 引数を設定することで取得することができます。このメソッドを使用すれば、国際化がより簡単になります。</p> <pre class="brush: js notranslate">var options = { weekday: 'long'}; console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95)); // Monday console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95)); // Montag </pre> </div> <h2 id="Specifications" name="Specifications">仕様書</h2> <table class="standard-table"> <thead> <tr> <th scope="col">仕様書</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('ESDraft', '#sec-date.prototype.getday', 'Date.prototype.getDay')}}</td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> <p>{{Compat("javascript.builtins.Date.getDay")}}</p> <h2 id="See_also" name="See_also">関連情報</h2> <ul> <li>{{jsxref("Date.prototype.getUTCDate()")}}</li> <li>{{jsxref("Date.prototype.getUTCDay()")}}</li> <li>{{jsxref("Date.prototype.setDate()")}}</li> </ul>