aboutsummaryrefslogtreecommitdiff
path: root/files/ca/web/javascript/reference/global_objects/date/toisostring/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ca/web/javascript/reference/global_objects/date/toisostring/index.html')
-rw-r--r--files/ca/web/javascript/reference/global_objects/date/toisostring/index.html134
1 files changed, 134 insertions, 0 deletions
diff --git a/files/ca/web/javascript/reference/global_objects/date/toisostring/index.html b/files/ca/web/javascript/reference/global_objects/date/toisostring/index.html
new file mode 100644
index 0000000000..759e53225c
--- /dev/null
+++ b/files/ca/web/javascript/reference/global_objects/date/toisostring/index.html
@@ -0,0 +1,134 @@
+---
+title: Date.prototype.toISOString()
+slug: Web/JavaScript/Referencia/Objectes_globals/Date/toISOString
+translation_of: Web/JavaScript/Reference/Global_Objects/Date/toISOString
+---
+<div>{{JSRef}}</div>
+
+<p>El mètode <strong><code>toISOString()</code></strong> retorna una cadena en un format ISO extès<em> simplificat </em>(<a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>), el qual sempre té 24 caràcters de llargària: <strong><code>YYYY-MM-DDTHH:mm:ss.sssZ</code></strong>. La zona horària és sempre UTC, tal i com indica el sufix <code>"Z"</code>.</p>
+
+<h2 id="Sintaxi">Sintaxi</h2>
+
+<pre class="syntaxbox"><code><var>dateObj</var>.toISOString()</code></pre>
+
+<h2 id="Exemples">Exemples</h2>
+
+<h3 id="Utilitzar_toISOString()">Utilitzar <code>toISOString()</code></h3>
+
+<pre class="brush: js">var today = new Date('05 October 2011 14:48 UTC');
+
+console.log(today.toISOString()); // Retorna 2011-10-05T14:48:00.000Z
+</pre>
+
+<p>L'exemple anterior interpreta una cadena no estàndard que pot no ser interpretada correctament per navegadors que no siguin mozilla.</p>
+
+<h2 id="Polyfill">Polyfill</h2>
+
+<p>Aquest mètode es va estandaritzar en la 5a edició d'ECMA-262. Els motors que no s'hagin actualitzat per suportar aquest mètode poden evitar al mancança d'aquest mètode utilitzant les següents accions:</p>
+
+<pre class="brush: js">if (!Date.prototype.toISOString) {
+ (function() {
+
+ function pad(number) {
+ if (number &lt; 10) {
+ return '0' + number;
+ }
+ return number;
+ }
+
+ Date.prototype.toISOString = function() {
+ return this.getUTCFullYear() +
+ '-' + pad(this.getUTCMonth() + 1) +
+ '-' + pad(this.getUTCDate()) +
+ 'T' + pad(this.getUTCHours()) +
+ ':' + pad(this.getUTCMinutes()) +
+ ':' + pad(this.getUTCSeconds()) +
+ '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
+ 'Z';
+ };
+
+ }());
+}
+</pre>
+
+<h2 id="Especificacions">Especificacions</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Especificació</th>
+ <th scope="col">Estat</th>
+ <th scope="col">Comentaris</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.9.5.43', 'Date.prototype.toISOString')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td>Definició inicial. Implementat en JavaScript 1.8.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatIE("9")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Android</th>
+ <th>Chrome per Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Vegeu_també">Vegeu també</h2>
+
+<ul>
+ <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li>
+ <li>{{jsxref("Date.prototype.toTimeString()")}}</li>
+ <li>{{jsxref("Date.prototype.toUTCString()")}}</li>
+</ul>