diff options
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/date/tostring/index.html')
| -rw-r--r-- | files/de/web/javascript/reference/global_objects/date/tostring/index.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/date/tostring/index.html b/files/de/web/javascript/reference/global_objects/date/tostring/index.html new file mode 100644 index 0000000000..470fd1903c --- /dev/null +++ b/files/de/web/javascript/reference/global_objects/date/tostring/index.html @@ -0,0 +1,94 @@ +--- +title: Date.prototype.toString() +slug: Web/JavaScript/Reference/Global_Objects/Date/toString +tags: + - Date + - JavaScript + - Method + - Prototype + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Date/toString +--- +<div>{{JSRef}}</div> + +<p>Die <strong><code>toString()</code></strong> Methode gibt einen String zurück, der ein spezifisches {{jsxref("Date")}} Objekt repräsentiert.</p> + +<div>{{EmbedInteractiveExample("pages/js/date-tostring.html")}}</div> + + + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox"><var>dateObj</var>.toString()</pre> + +<h3 id="Rückgabewert">Rückgabewert</h3> + +<p>Einen String, der das gegebene {{jsxref("Date")}} Objekt repräsentiert.</p> + +<h2 id="Beschreibung">Beschreibung</h2> + +<p>Das {{jsxref("Date")}} Objekt überschreibt die <code>toString()</code> Methode des {{jsxref("Object")}} Objekts. Es wird nicht von {{jsxref("Object.prototype.toString()")}} geerbt. Für {{jsxref("Date")}} Objekte gibt die <code>toString()</code> Methode einen String zurück, der das Objekt repräsentiert.</p> + +<p>Die <code>toString()</code> Methode gibt immer einen String zurück, der den Zeitpunkt repräsentiert. Dieser String wird in einem amerikanisch-englischen Format zurückgegeben.</p> + +<p>JavaScript ruft die <code>toString()</code> Methode automatisch auf, wenn ein {{jsxref("Date")}} Objekte als Text-Wert benötigt wird oder wenn das Objekt in einer String-Konkatination verwendet wird.</p> + +<p><code>toString()</code> ist eine generische Methode. Wenn <code>this</code> keine Instanz vom Typ {{jsxref("Date")}} ist, gibt die Methode "Invalid Date" zurück.</p> + +<h2 id="Beispiele">Beispiele</h2> + +<h3 id="Einsatz_von_toString()">Einsatz von <code>toString()</code></h3> + +<p>Im folgenden wird die Variable <code>myVar</code> mit dem Rückgabewert der <code>toString()</code> Methode eines {{jsxref("Date")}} Objektes beschrieben.</p> + +<pre class="brush: js">var x = new Date(); +myVar = x.toString(); // Weist der Variablen myVar folgenden Wert zu: + // Mon Sep 28 1998 14:36:22 GMT-0700 (PDT) +</pre> + +<h2 id="Spezifikationen">Spezifikationen</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Spezifikation</th> + <th scope="col">Status</th> + <th scope="col">Kommentar</th> + </tr> + <tr> + <td>{{SpecName('ES1')}}</td> + <td>{{Spec2('ES1')}}</td> + <td>Initiale Definition. Implementiert in JavaScript 1.0.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.9.5.2', 'Date.prototype.toLocaleTimeString')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-date.prototype.tostring', 'Date.prototype.toString')}}</td> + <td>{{Spec2('ES6')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-date.prototype.tostring', 'Date.prototype.toString')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browserkompatibilität">Browserkompatibilität</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("javascript.builtins.Date.toString")}}</p> + +<h2 id="Siehe_auch">Siehe auch</h2> + +<ul> + <li>{{jsxref("Object.prototype.toString()")}}</li> + <li>{{jsxref("Date.prototype.toDateString()")}}</li> + <li>{{jsxref("Date.prototype.toLocaleString()")}}</li> + <li>{{jsxref("Date.prototype.toTimeString()")}}</li> +</ul> |
