mozilla

Compare Revisions

Date.prototype.toString()

Change Revisions

Revision 417267:

Revision 417267 by Sheppy on

Revision 487109:

Revision 487109 by fscholz on

Title:
Date.toString
Date.prototype.toString()
Slug:
Web/JavaScript/Reference/Global_Objects/Date/toString
Web/JavaScript/Reference/Global_Objects/Date/toString
Tags:
"Date"
"Date", "JavaScript", "prototype", "Method"
Content:

Revision 417267
Revision 487109
nn7    <div>
8      {{JSRef("Global_Objects", "Date")}}
9    </div>
n11      Returns a string representing the specified Date object.n14      The <code><strong>toString()</strong></code> method returns
 > a string representing the specified Date object.
n13    <table class="standard-table">n
14      <thead>
15        <tr>
16          <th class="header" colspan="2">
17            Method of <a href="/en-US/docs/JavaScript/Reference/G
>lobal_Objects/Date" title="JavaScript/Reference/Global_Objects/Da 
>te"><code>Date</code></a> 
18          </th>
19        </tr>
20      </thead>
21      <tbody>
22        <tr>
23          <td>
24            Implemented in
25          </td>
26          <td>
27            JavaScript 1.0
28          </td>
29        </tr>
30        <tr>
31          <td>
32            ECMAScript Edition
33          </td>
34          <td>
35            ECMAScript 1st Edition
36          </td>
37        </tr>
38      </tbody>
39    </table>
n44<code>toString() </code>n20<var>dateObj</var>.toString()
n56      The <code><a href="/en-US/docs/JavaScript/Reference/Global_n32      The {{jsxref("Global_Object/Date", "Date")}} object overrid
>Objects/Date" title="JavaScript/Reference/Global_Objects/Date">Da>es the <code>toString</code> method of the {{jsxref("Global_Objec
>te</a></code> object overrides the <code>toString</code> method o>t/Object", "Object")}} object; it does not inherit {{jsxref("Obje
>f the <code><a href="/en-US/docs/JavaScript/Reference/Global_Obje>ct.prototype.toString()")}}. For {{jsxref("Global_Object/Date", "
>cts/Object" title="JavaScript/Reference/Global_Objects/Object">Ob>Date")}} objects, the <code>toString</code> method returns a stri
>ject</a></code> object; it does not inherit <code><a href="/en-US>ng representation of the object.
>/docs/JavaScript/Reference/Global_Objects/Object/toString" title= 
>"JavaScript/Reference/Global_Objects/Object/toString">Object.toSt 
>ring</a></code>. For <code><a href="/en-US/docs/JavaScript/Refere 
>nce/Global_Objects/Date" title="JavaScript/Reference/Global_Objec 
>ts/Date">Date</a></code> objects, the <code>toString</code> metho 
>d returns a string representation of the object. 
n75 n
76myVar=x.toString(); //assigns a value to myVar similar to:51myVar = x.toString(); // assigns a value to myVar similar to:
77                                        //Mon Sep 28 1998 14:36:252// Mon Sep 28 1998 14:36:22 GMT-0700 (Pacific Daylight Time)
>2 GMT-0700 (Pacific Daylight Time) 
nn54    <h2 id="Specifications">
55      Specifications
56    </h2>
57    <table class="standard-table">
58      <tbody>
59        <tr>
60          <th scope="col">
61            Specification
62          </th>
63          <th scope="col">
64            Status
65          </th>
66          <th scope="col">
67            Comment
68          </th>
69        </tr>
70        <tr>
71          <td>
72            ECMAScript 1st Edition. Implemented in JavaScript 1.0
73          </td>
74          <td>
75            Standard
76          </td>
77          <td>
78            Initial definition.
79          </td>
80        </tr>
81        <tr>
82          <td>
83            {{SpecName('ES5.1', '#sec-15.9.5.2', 'Date.prototype.
 >toLocaleTimeString')}}
84          </td>
85          <td>
86            {{Spec2('ES5.1')}}
87          </td>
88          <td>
89            &nbsp;
90          </td>
91        </tr>
92        <tr>
93          <td>
94            {{SpecName('ES6', '#sec-date.prototype.tostring', 'Da
 >te.prototype.toString')}}
95          </td>
96          <td>
97            {{Spec2('ES6')}}
98          </td>
99          <td>
100            &nbsp;
101          </td>
102        </tr>
103      </tbody>
104    </table>
105    <h2 id="Browser_compatibility">
106      Browser compatibility
107    </h2>
108    <p>
109      {{ CompatibilityTable() }}
110    </p>
111    <div id="compat-desktop">
112      <table class="compat-table">
113        <tbody>
114          <tr>
115            <th>
116              Feature
117            </th>
118            <th>
119              Chrome
120            </th>
121            <th>
122              Firefox (Gecko)
123            </th>
124            <th>
125              Internet Explorer
126            </th>
127            <th>
128              Opera
129            </th>
130            <th>
131              Safari
132            </th>
133          </tr>
134          <tr>
135            <td>
136              Basic support
137            </td>
138            <td>
139              {{ CompatVersionUnknown() }}
140            </td>
141            <td>
142              {{ CompatVersionUnknown() }}
143            </td>
144            <td>
145              {{ CompatVersionUnknown() }}
146            </td>
147            <td>
148              {{ CompatVersionUnknown() }}
149            </td>
150            <td>
151              {{ CompatVersionUnknown() }}
152            </td>
153          </tr>
154        </tbody>
155      </table>
156    </div>
157    <div id="compat-mobile">
158      <table class="compat-table">
159        <tbody>
160          <tr>
161            <th>
162              Feature
163            </th>
164            <th>
165              Android
166            </th>
167            <th>
168              Chrome for Android
169            </th>
170            <th>
171              Firefox Mobile (Gecko)
172            </th>
173            <th>
174              IE Mobile
175            </th>
176            <th>
177              Opera Mobile
178            </th>
179            <th>
180              Safari Mobile
181            </th>
182          </tr>
183          <tr>
184            <td>
185              Basic support
186            </td>
187            <td>
188              {{ CompatVersionUnknown() }}
189            </td>
190            <td>
191              {{ CompatVersionUnknown() }}
192            </td>
193            <td>
194              {{ CompatVersionUnknown() }}
195            </td>
196            <td>
197              {{ CompatVersionUnknown() }}
198            </td>
199            <td>
200              {{ CompatVersionUnknown() }}
201            </td>
202            <td>
203              {{ CompatVersionUnknown() }}
204            </td>
205          </tr>
206        </tbody>
207      </table>
208    </div>
79    <h2 id="See_also" name="See_also">209    <h2 id="See_Also" name="See_Also">
tt213      <li>{{jsxref("Object.prototype.toString()")}}
83      <li>214      </li>
84        <a href="/en-US/docs/JavaScript/Reference/Global_Objects/215      <li>{{jsxref("Date.prototype.toDateString()")}}
>Object/toString" title="JavaScript/Reference/Global_Objects/Objec 
>t/toString">Object.toString</a> 
85      </li>
86      <li>216      </li>
87        <a href="/en-US/docs/JavaScript/Reference/Global_Objects/217      <li>{{jsxref("Date.prototype.toLocaleString()")}}
>Date/toDateString" title="JavaScript/Reference/Global_Objects/Dat 
>e/toDateString">Date.toDateString</a> 
88      </li>
89      <li>218      </li>
90        <a href="/en-US/docs/JavaScript/Reference/Global_Objects/219      <li>{{jsxref("Date.prototype.toTimeString()")}}
>Date/toTimeString" title="JavaScript/Reference/Global_Objects/Dat 
>e/toTimeString">Date.toTimeString</a> 
91      </li>
92      <li>
93        <a href="/en-US/docs/JavaScript/Reference/Global_Objects/
>Date/toLocaleString" title="JavaScript/Reference/Global_Objects/D 
>ate/toLocaleString">Date.toLocaleString</a> 

Back to History