diff options
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/date/todatestring/index.html')
| -rw-r--r-- | files/ja/web/javascript/reference/global_objects/date/todatestring/index.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/date/todatestring/index.html b/files/ja/web/javascript/reference/global_objects/date/todatestring/index.html new file mode 100644 index 0000000000..397ca3a281 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/date/todatestring/index.html @@ -0,0 +1,84 @@ +--- +title: Date.prototype.toDateString() +slug: Web/JavaScript/Reference/Global_Objects/Date/toDateString +tags: + - Date + - JavaScript + - Method + - Prototype + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Date/toDateString +--- +<div>{{JSRef}}</div> + +<p><strong><code>toDateString()</code></strong> メソッドは、 {{jsxref("Date")}} オブジェクトの日付部分を英語の次の書式で空白区切りで返します。</p> + +<ol> + <li>曜日名の最初の3文字</li> + <li>月名の最初の3文字</li> + <li>2桁の日、必要であれば左に0埋め</li> + <li>4桁 (以上) の年、必要であれば左に0埋め</li> +</ol> + +<p>例 "Thu Jan 01 1970".</p> + +<div>{{EmbedInteractiveExample("pages/js/date-todatestring.html")}}</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>.toDateString()</pre> + +<h3 id="Return_value" name="Return_value">返値</h3> + +<p>与えられた {{jsxref("Date")}} オブジェクトの「日付」部を表す文字列を人間が読める英語の表記で返します。</p> + +<h2 id="Description" name="Description">解説</h2> + +<p>{{jsxref("Date")}} インスタンスは、特定の時点を参照します。{{jsxref("Date.prototype.toString()", "toString()")}} を呼び出すと、人間が読める英語の表記で日付を返します。<a href="/ja/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> では、この文字列は「日付」部 (日、月、年) と続く「時刻」部 (時、分、秒、タイムゾーン) からなります。時々、時刻の文字列を得たいことがあるでしょう。そのような場合は {{jsxref("Date.prototype.toTimeString()", "toTimeString()")}} メソッドが使えます。</p> + +<p><a href="/ja/docs/Web/JavaScript/Language_Resources">ECMA-262</a> に従って実装されたエンジンは、{{jsxref("Date")}} オブジェクトに対して {{jsxref("Date.prototype.toString()", "toString()")}} メソッドから得られる文字列と異なることがあるため、<code>toDateString()</code> メソッドは特に役立ちます。その文字列の表記は実装依存であり、単純に文字列を切り出す方法では、複数のエンジンで一貫した結果を得られない可能性があります。</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="A_basic_usage_of_toDateString" name="A_basic_usage_of_toDateString">toDateString() の基本的な使い方</h3> + +<pre class="brush: js notranslate">var d = new Date(1993, 5, 28, 14, 39, 7); + +console.log(d.toString()); // logs Mon Jun 28 1993 14:39:07 GMT-0600 (PDT) +console.log(d.toDateString()); // logs Mon Jun 28 1993 +</pre> + +<div class="note"> +<p><strong>注:</strong> {{jsxref("Date")}} の引数として使用する場合、月は 0 から始まります(よって、 0 は 1 月に、 11 は 12 月 に対応します)。</p> +</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.todatestring', 'Date.prototype.toDateString')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Date.toDateString")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li> + <li>{{jsxref("Date.prototype.toTimeString()")}}</li> + <li>{{jsxref("Date.prototype.toString()")}}</li> +</ul> |
