1 | <div class="body-wrap"> |
---|
2 | <div class="top-tools"> |
---|
3 | <a class="inner-link" href="#Date-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a> |
---|
4 | <a class="inner-link" href="#Date-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a> |
---|
5 | <a class="inner-link" href="#Date-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a> |
---|
6 | <a class="bookmark" href="../docs/?class=Date"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a> |
---|
7 | </div> |
---|
8 | <h1>Class Date</h1> |
---|
9 | <table cellspacing="0"> |
---|
10 | <tr><td class="label">Package:</td><td class="hd-info">Global</td></tr> |
---|
11 | <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/Date.js" target="_blank">Date.js</a></td></tr> |
---|
12 | <tr><td class="label">Class:</td><td class="hd-info">Date</td></tr> |
---|
13 | <tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr> |
---|
14 | </table> |
---|
15 | <div class="description"> |
---|
16 | * |
---|
17 | The date parsing and format syntax is a subset of |
---|
18 | <a href="http://www.php.net/date">PHP's date() function</a>, and the formats that are |
---|
19 | supported will provide results equivalent to their PHP versions. |
---|
20 | The following is a list of all currently supported formats: |
---|
21 | <pre>Format Description Example returned values |
---|
22 | ------ ----------------------------------------------------------------------- ----------------------- |
---|
23 | d Day of the month, 2 digits with leading zeros 01 to 31 |
---|
24 | D A short textual representation of the day of the week Mon to Sun |
---|
25 | j Day of the month without leading zeros 1 to 31 |
---|
26 | l A full textual representation of the day of the week Sunday to Saturday |
---|
27 | N ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday) |
---|
28 | S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j |
---|
29 | w Numeric representation of the day of the week 0 (for Sunday) to 6 (for Saturday) |
---|
30 | z The day of the year (starting from 0) 0 to 364 (365 in leap years) |
---|
31 | W ISO-8601 week number of year, weeks starting on Monday 01 to 53 |
---|
32 | F A full textual representation of a month, such as January or March January to December |
---|
33 | m Numeric representation of a month, with leading zeros 01 to 12 |
---|
34 | M A short textual representation of a month Jan to Dec |
---|
35 | n Numeric representation of a month, without leading zeros 1 to 12 |
---|
36 | t Number of days in the given month 28 to 31 |
---|
37 | L Whether it's a leap year 1 if it is a leap year, 0 otherwise. |
---|
38 | o ISO-8601 year number (identical to (Y), but if the ISO week number (W) Examples: 1998 or 2004 |
---|
39 | belongs to the previous or next year, that year is used instead) |
---|
40 | Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003 |
---|
41 | y A two digit representation of a year Examples: 99 or 03 |
---|
42 | a Lowercase Ante meridiem and Post meridiem am or pm |
---|
43 | A Uppercase Ante meridiem and Post meridiem AM or PM |
---|
44 | g 12-hour format of an hour without leading zeros 1 to 12 |
---|
45 | G 24-hour format of an hour without leading zeros 0 to 23 |
---|
46 | h 12-hour format of an hour with leading zeros 01 to 12 |
---|
47 | H 24-hour format of an hour with leading zeros 00 to 23 |
---|
48 | i Minutes, with leading zeros 00 to 59 |
---|
49 | s Seconds, with leading zeros 00 to 59 |
---|
50 | u Decimal fraction of a second Examples: |
---|
51 | (minimum 1 digit, arbitrary number of digits allowed) 001 (i.e. 0.001s) or |
---|
52 | 100 (i.e. 0.100s) or |
---|
53 | 999 (i.e. 0.999s) or |
---|
54 | 999876543210 (i.e. 0.999876543210s) |
---|
55 | O Difference to Greenwich time (GMT) in hours and minutes Example: +1030 |
---|
56 | P Difference to Greenwich time (GMT) with colon between hours and minutes Example: -08:00 |
---|
57 | T Timezone abbreviation of the machine running the code Examples: EST, MDT, PDT ... |
---|
58 | Z Timezone offset in seconds (negative if west of UTC, positive if east) -43200 to 50400 |
---|
59 | c ISO 8601 date (note: the decimal fraction of a second, if specified, Examples: |
---|
60 | must contain at least 1 digit. There is no limit on the maximum number 2007-04-17T15:19:21+08:00 or |
---|
61 | of digits allowed. see http://www.w3.org/TR/NOTE-datetime for more info) 2008-03-16T16:18:22Z or |
---|
62 | 2009-02-15T17:17:23.9+01:00 or |
---|
63 | 2010-01-14T18:16:24,999876543-07:00 |
---|
64 | U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 1193432466 or -2138434463</pre> |
---|
65 | Example usage (note that you must escape format specifiers with '\\' to render them as character literals): |
---|
66 | <pre><code><i>// Sample date:</i> |
---|
67 | <i>// <em>'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'</em></i> |
---|
68 | |
---|
69 | <b>var</b> dt = <b>new</b> Date(<em>'1/10/2007 03:05:01 PM GMT-0600'</em>); |
---|
70 | document.write(dt.format(<em>'Y-m-d'</em>)); <i>// 2007-01-10</i> |
---|
71 | document.write(dt.format(<em>'F j, Y, g:i a'</em>)); <i>// January 10, 2007, 3:05 pm</i> |
---|
72 | document.write(dt.format(<em>'l, \\t\\he jS \\of F Y h:i:s A'</em>)); // Wednesday, the 10th of January 2007 03:05:01 PM</code></pre> |
---|
73 | Here are some standard date/time patterns that you might find helpful. They |
---|
74 | are not part of the source of Date.js, but to use them you can simply copy this |
---|
75 | block of code into any script that is included after Date.js and they will also become |
---|
76 | globally available on the Date object. Feel free to add or remove patterns as needed in your code. |
---|
77 | <pre><code>Date.patterns = { |
---|
78 | ISO8601Long:<em>"Y-m-d H:i:s"</em>, |
---|
79 | ISO8601Short:<em>"Y-m-d"</em>, |
---|
80 | ShortDate: <em>"n/j/Y"</em>, |
---|
81 | LongDate: <em>"l, F d, Y"</em>, |
---|
82 | FullDateTime: <em>"l, F d, Y g:i:s A"</em>, |
---|
83 | MonthDay: <em>"F d"</em>, |
---|
84 | ShortTime: <em>"g:i A"</em>, |
---|
85 | LongTime: <em>"g:i:s A"</em>, |
---|
86 | SortableDateTime: <em>"Y-m-d\\TH:i:s"</em>, |
---|
87 | UniversalSortableDateTime: <em>"Y-m-d H:i:sO"</em>, |
---|
88 | YearMonth: <em>"F, Y"</em> |
---|
89 | };</code></pre> |
---|
90 | Example usage: |
---|
91 | <pre><code>var dt = <b>new</b> Date(); |
---|
92 | document.write(dt.format(Date.patterns.ShortDate));</code></pre> </div> |
---|
93 | |
---|
94 | <div class="hr"></div> |
---|
95 | <a id="Date-props"></a> |
---|
96 | <h2>Public Properties</h2> |
---|
97 | <table cellspacing="0" class="member-table"> |
---|
98 | <tr> |
---|
99 | <th class="sig-header" colspan="2">Property</th> |
---|
100 | <th class="msource-header">Defined By</th> |
---|
101 | </tr> |
---|
102 | <tr class="property-row"> |
---|
103 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
104 | <td class="sig"> |
---|
105 | <a id="Date-DAY"></a> |
---|
106 | <b>DAY</b> : String <div class="mdesc"> |
---|
107 | <static> Date interval constant </div> |
---|
108 | </td> |
---|
109 | <td class="msource">Date</td> |
---|
110 | </tr> |
---|
111 | <tr class="property-row alt"> |
---|
112 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
113 | <td class="sig"> |
---|
114 | <a id="Date-HOUR"></a> |
---|
115 | <b>HOUR</b> : String <div class="mdesc"> |
---|
116 | <static> Date interval constant </div> |
---|
117 | </td> |
---|
118 | <td class="msource">Date</td> |
---|
119 | </tr> |
---|
120 | <tr class="property-row"> |
---|
121 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
122 | <td class="sig"> |
---|
123 | <a id="Date-MILLI"></a> |
---|
124 | <b>MILLI</b> : String <div class="mdesc"> |
---|
125 | <static> Date interval constant </div> |
---|
126 | </td> |
---|
127 | <td class="msource">Date</td> |
---|
128 | </tr> |
---|
129 | <tr class="property-row alt"> |
---|
130 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
131 | <td class="sig"> |
---|
132 | <a id="Date-MINUTE"></a> |
---|
133 | <b>MINUTE</b> : String <div class="mdesc"> |
---|
134 | <static> Date interval constant </div> |
---|
135 | </td> |
---|
136 | <td class="msource">Date</td> |
---|
137 | </tr> |
---|
138 | <tr class="property-row"> |
---|
139 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
140 | <td class="sig"> |
---|
141 | <a id="Date-MONTH"></a> |
---|
142 | <b>MONTH</b> : String <div class="mdesc"> |
---|
143 | <static> Date interval constant </div> |
---|
144 | </td> |
---|
145 | <td class="msource">Date</td> |
---|
146 | </tr> |
---|
147 | <tr class="property-row alt"> |
---|
148 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
149 | <td class="sig"> |
---|
150 | <a id="Date-SECOND"></a> |
---|
151 | <b>SECOND</b> : String <div class="mdesc"> |
---|
152 | <static> Date interval constant </div> |
---|
153 | </td> |
---|
154 | <td class="msource">Date</td> |
---|
155 | </tr> |
---|
156 | <tr class="property-row"> |
---|
157 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
158 | <td class="sig"> |
---|
159 | <a id="Date-YEAR"></a> |
---|
160 | <b>YEAR</b> : String <div class="mdesc"> |
---|
161 | <static> Date interval constant </div> |
---|
162 | </td> |
---|
163 | <td class="msource">Date</td> |
---|
164 | </tr> |
---|
165 | <tr class="property-row alt expandable"> |
---|
166 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
167 | <td class="sig"> |
---|
168 | <a id="Date-dayNames"></a> |
---|
169 | <b>dayNames</b> : Array <div class="mdesc"> |
---|
170 | <div class="short"><static> An array of textual day names. |
---|
171 | Override these values for international dates. |
---|
172 | Example: |
---|
173 | Date.dayNames =...</div> |
---|
174 | <div class="long"> |
---|
175 | <static> An array of textual day names. |
---|
176 | Override these values for international dates. |
---|
177 | Example: |
---|
178 | <pre><code>Date.dayNames = [ |
---|
179 | <em>'SundayInYourLang'</em>, |
---|
180 | <em>'MondayInYourLang'</em>, |
---|
181 | ... |
---|
182 | ];</code></pre> </div> |
---|
183 | </div> |
---|
184 | </td> |
---|
185 | <td class="msource">Date</td> |
---|
186 | </tr> |
---|
187 | <tr class="property-row expandable"> |
---|
188 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
189 | <td class="sig"> |
---|
190 | <a id="Date-formatCodes"></a> |
---|
191 | <b>formatCodes</b> : Object <div class="mdesc"> |
---|
192 | <div class="short"><static> The base format-code to formatting-function hashmap used by the format method. |
---|
193 | Formatting functions ar...</div> |
---|
194 | <div class="long"> |
---|
195 | <static> The base format-code to formatting-function hashmap used by the <a ext:cls="Date" ext:member="format" href="output/Date.html#format">format</a> method. |
---|
196 | Formatting functions are strings (or functions which return strings) which |
---|
197 | will return the appropriate value when evaluated in the context of the Date object |
---|
198 | from which the <a ext:cls="Date" ext:member="format" href="output/Date.html#format">format</a> method is called. |
---|
199 | Add to / override these mappings for custom date formatting. |
---|
200 | Note: Date.format() treats characters as literals if an appropriate mapping cannot be found. |
---|
201 | Example: |
---|
202 | <pre><code>Date.formatCodes.x = <em>"String.leftPad(<b>this</b>.getDate(), 2, '0')"</em>; |
---|
203 | (<b>new</b> Date()).format(<em>"X"</em>); // returns the current day of the month</code></pre> </div> |
---|
204 | </div> |
---|
205 | </td> |
---|
206 | <td class="msource">Date</td> |
---|
207 | </tr> |
---|
208 | <tr class="property-row alt expandable"> |
---|
209 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
210 | <td class="sig"> |
---|
211 | <a id="Date-monthNames"></a> |
---|
212 | <b>monthNames</b> : Array <div class="mdesc"> |
---|
213 | <div class="short"><static> An array of textual month names. |
---|
214 | Override these values for international dates. |
---|
215 | Example: |
---|
216 | Date.monthNam...</div> |
---|
217 | <div class="long"> |
---|
218 | <static> An array of textual month names. |
---|
219 | Override these values for international dates. |
---|
220 | Example: |
---|
221 | <pre><code>Date.monthNames = [ |
---|
222 | <em>'JanInYourLang'</em>, |
---|
223 | <em>'FebInYourLang'</em>, |
---|
224 | ... |
---|
225 | ];</code></pre> </div> |
---|
226 | </div> |
---|
227 | </td> |
---|
228 | <td class="msource">Date</td> |
---|
229 | </tr> |
---|
230 | <tr class="property-row expandable"> |
---|
231 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
232 | <td class="sig"> |
---|
233 | <a id="Date-monthNumbers"></a> |
---|
234 | <b>monthNumbers</b> : Object <div class="mdesc"> |
---|
235 | <div class="short"><static> An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are ...</div> |
---|
236 | <div class="long"> |
---|
237 | <static> An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are case-sensitive). |
---|
238 | Override these values for international dates. |
---|
239 | Example: |
---|
240 | <pre><code>Date.monthNumbers = { |
---|
241 | <em>'ShortJanNameInYourLang'</em>:0, |
---|
242 | <em>'ShortFebNameInYourLang'</em>:1, |
---|
243 | ... |
---|
244 | };</code></pre> </div> |
---|
245 | </div> |
---|
246 | </td> |
---|
247 | <td class="msource">Date</td> |
---|
248 | </tr> |
---|
249 | </table> |
---|
250 | <a id="Date-methods"></a> |
---|
251 | <h2>Public Methods</h2> |
---|
252 | <table cellspacing="0" class="member-table"> |
---|
253 | <tr> |
---|
254 | <th class="sig-header" colspan="2">Method</th> |
---|
255 | <th class="msource-header">Defined By</th> |
---|
256 | </tr> |
---|
257 | <tr class="method-row expandable"> |
---|
258 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
259 | <td class="sig"> |
---|
260 | <a id="Date-add"></a> |
---|
261 | <b>add</b>( <code>String interval</code>, <code>Number value</code> ) : Date <div class="mdesc"> |
---|
262 | <div class="short">Provides a convenient method of performing basic date arithmetic. This method |
---|
263 | does not modify the Date instance bein...</div> |
---|
264 | <div class="long"> |
---|
265 | Provides a convenient method of performing basic date arithmetic. This method |
---|
266 | does not modify the Date instance being called - it creates and returns |
---|
267 | a new Date instance containing the resulting date value. |
---|
268 | Examples: |
---|
269 | <pre><code><i>//Basic usage:</i> |
---|
270 | <b>var</b> dt = <b>new</b> Date(<em>'10/29/2006'</em>).add(Date.DAY, 5); |
---|
271 | document.write(dt); <i>//returns <em>'Fri Oct 06 2006 00:00:00'</em></i> |
---|
272 | |
---|
273 | <i>//Negative values will subtract correctly:</i> |
---|
274 | <b>var</b> dt2 = <b>new</b> Date(<em>'10/1/2006'</em>).add(Date.DAY, -5); |
---|
275 | document.write(dt2); <i>//returns <em>'Tue Sep 26 2006 00:00:00'</em></i> |
---|
276 | |
---|
277 | <i>//You can even chain several calls together <b>in</b> one line!</i> |
---|
278 | <b>var</b> dt3 = <b>new</b> Date(<em>'10/1/2006'</em>).add(Date.DAY, 5).add(Date.HOUR, 8).add(Date.MINUTE, -30); |
---|
279 | document.write(dt3); //returns <em>'Fri Oct 06 2006 07:30:00'</em></code></pre> <div class="mdetail-params"> |
---|
280 | <strong>Parameters:</strong> |
---|
281 | <ul><li><code>interval</code> : String<div class="sub-desc">A valid date interval enum value.</div></li><li><code>value</code> : Number<div class="sub-desc">The amount to add to the current date.</div></li> </ul> |
---|
282 | <strong>Returns:</strong> |
---|
283 | <ul> |
---|
284 | <li><code>Date</code><div class="sub-desc">The new Date instance.</div></li> |
---|
285 | </ul> |
---|
286 | </div> |
---|
287 | </div> |
---|
288 | </div> |
---|
289 | </td> |
---|
290 | <td class="msource">Date</td> |
---|
291 | </tr> |
---|
292 | <tr class="method-row alt expandable"> |
---|
293 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
294 | <td class="sig"> |
---|
295 | <a id="Date-between"></a> |
---|
296 | <b>between</b>( <code>Date start</code>, <code>Date end</code> ) : Boolean <div class="mdesc"> |
---|
297 | <div class="short">Checks if this date falls on or between the given start and end dates.</div> |
---|
298 | <div class="long"> |
---|
299 | Checks if this date falls on or between the given start and end dates. <div class="mdetail-params"> |
---|
300 | <strong>Parameters:</strong> |
---|
301 | <ul><li><code>start</code> : Date<div class="sub-desc">Start date</div></li><li><code>end</code> : Date<div class="sub-desc">End date</div></li> </ul> |
---|
302 | <strong>Returns:</strong> |
---|
303 | <ul> |
---|
304 | <li><code>Boolean</code><div class="sub-desc">true if this date falls on or between the given start and end dates.</div></li> |
---|
305 | </ul> |
---|
306 | </div> |
---|
307 | </div> |
---|
308 | </div> |
---|
309 | </td> |
---|
310 | <td class="msource">Date</td> |
---|
311 | </tr> |
---|
312 | <tr class="method-row expandable"> |
---|
313 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
314 | <td class="sig"> |
---|
315 | <a id="Date-clearTime"></a> |
---|
316 | <b>clearTime</b>( <code>Boolean clone</code> ) : Date <div class="mdesc"> |
---|
317 | <div class="short">Clears any time information from this date.</div> |
---|
318 | <div class="long"> |
---|
319 | Clears any time information from this date. <div class="mdetail-params"> |
---|
320 | <strong>Parameters:</strong> |
---|
321 | <ul><li><code>clone</code> : Boolean<div class="sub-desc">true to create a clone of this date, clear the time and return it (defaults to false).</div></li> </ul> |
---|
322 | <strong>Returns:</strong> |
---|
323 | <ul> |
---|
324 | <li><code>Date</code><div class="sub-desc">this or the clone.</div></li> |
---|
325 | </ul> |
---|
326 | </div> |
---|
327 | </div> |
---|
328 | </div> |
---|
329 | </td> |
---|
330 | <td class="msource">Date</td> |
---|
331 | </tr> |
---|
332 | <tr class="method-row alt expandable"> |
---|
333 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
334 | <td class="sig"> |
---|
335 | <a id="Date-clone"></a> |
---|
336 | <b>clone</b>() : Date <div class="mdesc"> |
---|
337 | <div class="short">Creates and returns a new Date instance with the exact same date value as the called instance. |
---|
338 | Dates are copied and p...</div> |
---|
339 | <div class="long"> |
---|
340 | Creates and returns a new Date instance with the exact same date value as the called instance. |
---|
341 | Dates are copied and passed by reference, so if a copied date variable is modified later, the original |
---|
342 | variable will also be changed. When the intention is to create a new variable that will not |
---|
343 | modify the original instance, you should create a clone. |
---|
344 | Example of correctly cloning a date: |
---|
345 | <pre><code><i>//wrong way:</i> |
---|
346 | <b>var</b> orig = <b>new</b> Date(<em>'10/1/2006'</em>); |
---|
347 | <b>var</b> copy = orig; |
---|
348 | copy.setDate(5); |
---|
349 | document.write(orig); <i>//returns <em>'Thu Oct 05 2006'</em>!</i> |
---|
350 | |
---|
351 | <i>//correct way:</i> |
---|
352 | <b>var</b> orig = <b>new</b> Date(<em>'10/1/2006'</em>); |
---|
353 | <b>var</b> copy = orig.clone(); |
---|
354 | copy.setDate(5); |
---|
355 | document.write(orig); //returns <em>'Thu Oct 01 2006'</em></code></pre> <div class="mdetail-params"> |
---|
356 | <strong>Parameters:</strong> |
---|
357 | <ul><li>None.</li> </ul> |
---|
358 | <strong>Returns:</strong> |
---|
359 | <ul> |
---|
360 | <li><code>Date</code><div class="sub-desc">The new Date instance.</div></li> |
---|
361 | </ul> |
---|
362 | </div> |
---|
363 | </div> |
---|
364 | </div> |
---|
365 | </td> |
---|
366 | <td class="msource">Date</td> |
---|
367 | </tr> |
---|
368 | <tr class="method-row expandable"> |
---|
369 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
370 | <td class="sig"> |
---|
371 | <a id="Date-format"></a> |
---|
372 | <b>format</b>( <code>String format</code> ) : String <div class="mdesc"> |
---|
373 | <div class="short">Formats a date given the supplied format string.</div> |
---|
374 | <div class="long"> |
---|
375 | Formats a date given the supplied format string. <div class="mdetail-params"> |
---|
376 | <strong>Parameters:</strong> |
---|
377 | <ul><li><code>format</code> : String<div class="sub-desc">The format string.</div></li> </ul> |
---|
378 | <strong>Returns:</strong> |
---|
379 | <ul> |
---|
380 | <li><code>String</code><div class="sub-desc">The formatted date.</div></li> |
---|
381 | </ul> |
---|
382 | </div> |
---|
383 | </div> |
---|
384 | </div> |
---|
385 | </td> |
---|
386 | <td class="msource">Date</td> |
---|
387 | </tr> |
---|
388 | <tr class="method-row alt expandable"> |
---|
389 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
390 | <td class="sig"> |
---|
391 | <a id="Date-getDayOfYear"></a> |
---|
392 | <b>getDayOfYear</b>() : Number <div class="mdesc"> |
---|
393 | <div class="short">Get the numeric day number of the year, adjusted for leap year.</div> |
---|
394 | <div class="long"> |
---|
395 | Get the numeric day number of the year, adjusted for leap year. <div class="mdetail-params"> |
---|
396 | <strong>Parameters:</strong> |
---|
397 | <ul><li>None.</li> </ul> |
---|
398 | <strong>Returns:</strong> |
---|
399 | <ul> |
---|
400 | <li><code>Number</code><div class="sub-desc">0 to 364 (365 in leap years).</div></li> |
---|
401 | </ul> |
---|
402 | </div> |
---|
403 | </div> |
---|
404 | </div> |
---|
405 | </td> |
---|
406 | <td class="msource">Date</td> |
---|
407 | </tr> |
---|
408 | <tr class="method-row expandable"> |
---|
409 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
410 | <td class="sig"> |
---|
411 | <a id="Date-getDaysInMonth"></a> |
---|
412 | <b>getDaysInMonth</b>() : Number <div class="mdesc"> |
---|
413 | <div class="short">Get the number of days in the current month, adjusted for leap year.</div> |
---|
414 | <div class="long"> |
---|
415 | Get the number of days in the current month, adjusted for leap year. <div class="mdetail-params"> |
---|
416 | <strong>Parameters:</strong> |
---|
417 | <ul><li>None.</li> </ul> |
---|
418 | <strong>Returns:</strong> |
---|
419 | <ul> |
---|
420 | <li><code>Number</code><div class="sub-desc">The number of days in the month.</div></li> |
---|
421 | </ul> |
---|
422 | </div> |
---|
423 | </div> |
---|
424 | </div> |
---|
425 | </td> |
---|
426 | <td class="msource">Date</td> |
---|
427 | </tr> |
---|
428 | <tr class="method-row alt expandable"> |
---|
429 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
430 | <td class="sig"> |
---|
431 | <a id="Date-getElapsed"></a> |
---|
432 | <b>getElapsed</b>( <span class="optional" title="Optional">[<code>Date date</code>]</span> ) : Number <div class="mdesc"> |
---|
433 | <div class="short">Returns the number of milliseconds between this date and date</div> |
---|
434 | <div class="long"> |
---|
435 | Returns the number of milliseconds between this date and date <div class="mdetail-params"> |
---|
436 | <strong>Parameters:</strong> |
---|
437 | <ul><li><code>date</code> : Date<div class="sub-desc">(optional) Defaults to now</div></li> </ul> |
---|
438 | <strong>Returns:</strong> |
---|
439 | <ul> |
---|
440 | <li><code>Number</code><div class="sub-desc">The diff in milliseconds</div></li> |
---|
441 | </ul> |
---|
442 | </div> |
---|
443 | </div> |
---|
444 | </div> |
---|
445 | </td> |
---|
446 | <td class="msource">Date</td> |
---|
447 | </tr> |
---|
448 | <tr class="method-row expandable"> |
---|
449 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
450 | <td class="sig"> |
---|
451 | <a id="Date-getFirstDateOfMonth"></a> |
---|
452 | <b>getFirstDateOfMonth</b>() : Date <div class="mdesc"> |
---|
453 | <div class="short">Get the date of the first day of the month in which this date resides.</div> |
---|
454 | <div class="long"> |
---|
455 | Get the date of the first day of the month in which this date resides. <div class="mdetail-params"> |
---|
456 | <strong>Parameters:</strong> |
---|
457 | <ul><li>None.</li> </ul> |
---|
458 | <strong>Returns:</strong> |
---|
459 | <ul> |
---|
460 | <li><code>Date</code></li> |
---|
461 | </ul> |
---|
462 | </div> |
---|
463 | </div> |
---|
464 | </div> |
---|
465 | </td> |
---|
466 | <td class="msource">Date</td> |
---|
467 | </tr> |
---|
468 | <tr class="method-row alt expandable"> |
---|
469 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
470 | <td class="sig"> |
---|
471 | <a id="Date-getFirstDayOfMonth"></a> |
---|
472 | <b>getFirstDayOfMonth</b>() : Number <div class="mdesc"> |
---|
473 | <div class="short">Get the first day of the current month, adjusted for leap year. The returned value |
---|
474 | is the numeric day index within t...</div> |
---|
475 | <div class="long"> |
---|
476 | Get the first day of the current month, adjusted for leap year. The returned value |
---|
477 | is the numeric day index within the week (0-6) which can be used in conjunction with |
---|
478 | the <a ext:cls="Date" ext:member="monthNames" href="output/Date.html#monthNames">monthNames</a> array to retrieve the textual day name. |
---|
479 | Example: |
---|
480 | <pre><code>var dt = <b>new</b> Date(<em>'1/10/2007'</em>); |
---|
481 | document.write(Date.dayNames[dt.getFirstDayOfMonth()]); //output: <em>'Monday'</em></code></pre> <div class="mdetail-params"> |
---|
482 | <strong>Parameters:</strong> |
---|
483 | <ul><li>None.</li> </ul> |
---|
484 | <strong>Returns:</strong> |
---|
485 | <ul> |
---|
486 | <li><code>Number</code><div class="sub-desc">The day number (0-6).</div></li> |
---|
487 | </ul> |
---|
488 | </div> |
---|
489 | </div> |
---|
490 | </div> |
---|
491 | </td> |
---|
492 | <td class="msource">Date</td> |
---|
493 | </tr> |
---|
494 | <tr class="method-row expandable"> |
---|
495 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
496 | <td class="sig"> |
---|
497 | <a id="Date-getGMTOffset"></a> |
---|
498 | <b>getGMTOffset</b>( <code>Boolean colon</code> ) : String <div class="mdesc"> |
---|
499 | <div class="short">Get the offset from GMT of the current date (equivalent to the format specifier 'O').</div> |
---|
500 | <div class="long"> |
---|
501 | Get the offset from GMT of the current date (equivalent to the format specifier 'O'). <div class="mdetail-params"> |
---|
502 | <strong>Parameters:</strong> |
---|
503 | <ul><li><code>colon</code> : Boolean<div class="sub-desc">true to separate the hours and minutes with a colon (defaults to false).</div></li> </ul> |
---|
504 | <strong>Returns:</strong> |
---|
505 | <ul> |
---|
506 | <li><code>String</code><div class="sub-desc">The 4-character offset string prefixed with + or - (e.g. '-0600').</div></li> |
---|
507 | </ul> |
---|
508 | </div> |
---|
509 | </div> |
---|
510 | </div> |
---|
511 | </td> |
---|
512 | <td class="msource">Date</td> |
---|
513 | </tr> |
---|
514 | <tr class="method-row alt expandable"> |
---|
515 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
516 | <td class="sig"> |
---|
517 | <a id="Date-getLastDateOfMonth"></a> |
---|
518 | <b>getLastDateOfMonth</b>() : Date <div class="mdesc"> |
---|
519 | <div class="short">Get the date of the last day of the month in which this date resides.</div> |
---|
520 | <div class="long"> |
---|
521 | Get the date of the last day of the month in which this date resides. <div class="mdetail-params"> |
---|
522 | <strong>Parameters:</strong> |
---|
523 | <ul><li>None.</li> </ul> |
---|
524 | <strong>Returns:</strong> |
---|
525 | <ul> |
---|
526 | <li><code>Date</code></li> |
---|
527 | </ul> |
---|
528 | </div> |
---|
529 | </div> |
---|
530 | </div> |
---|
531 | </td> |
---|
532 | <td class="msource">Date</td> |
---|
533 | </tr> |
---|
534 | <tr class="method-row expandable"> |
---|
535 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
536 | <td class="sig"> |
---|
537 | <a id="Date-getLastDayOfMonth"></a> |
---|
538 | <b>getLastDayOfMonth</b>() : Number <div class="mdesc"> |
---|
539 | <div class="short">Get the last day of the current month, adjusted for leap year. The returned value |
---|
540 | is the numeric day index within th...</div> |
---|
541 | <div class="long"> |
---|
542 | Get the last day of the current month, adjusted for leap year. The returned value |
---|
543 | is the numeric day index within the week (0-6) which can be used in conjunction with |
---|
544 | the <a ext:cls="Date" ext:member="monthNames" href="output/Date.html#monthNames">monthNames</a> array to retrieve the textual day name. |
---|
545 | Example: |
---|
546 | <pre><code>var dt = <b>new</b> Date(<em>'1/10/2007'</em>); |
---|
547 | document.write(Date.dayNames[dt.getLastDayOfMonth()]); //output: <em>'Wednesday'</em></code></pre> <div class="mdetail-params"> |
---|
548 | <strong>Parameters:</strong> |
---|
549 | <ul><li>None.</li> </ul> |
---|
550 | <strong>Returns:</strong> |
---|
551 | <ul> |
---|
552 | <li><code>Number</code><div class="sub-desc">The day number (0-6).</div></li> |
---|
553 | </ul> |
---|
554 | </div> |
---|
555 | </div> |
---|
556 | </div> |
---|
557 | </td> |
---|
558 | <td class="msource">Date</td> |
---|
559 | </tr> |
---|
560 | <tr class="method-row alt expandable"> |
---|
561 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
562 | <td class="sig"> |
---|
563 | <a id="Date-getMonthNumber"></a> |
---|
564 | <b>getMonthNumber</b>( <code>String name</code> ) : Number <div class="mdesc"> |
---|
565 | <div class="short"><static> Get the zero-based javascript month number for the given short/full month name. |
---|
566 | Override this function...</div> |
---|
567 | <div class="long"> |
---|
568 | <static> Get the zero-based javascript month number for the given short/full month name. |
---|
569 | Override this function for international dates. <div class="mdetail-params"> |
---|
570 | <strong>Parameters:</strong> |
---|
571 | <ul><li><code>name</code> : String<div class="sub-desc">The short/full month name.</div></li> </ul> |
---|
572 | <strong>Returns:</strong> |
---|
573 | <ul> |
---|
574 | <li><code>Number</code><div class="sub-desc">The zero-based javascript month number.</div></li> |
---|
575 | </ul> |
---|
576 | </div> |
---|
577 | </div> |
---|
578 | </div> |
---|
579 | </td> |
---|
580 | <td class="msource">Date</td> |
---|
581 | </tr> |
---|
582 | <tr class="method-row expandable"> |
---|
583 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
584 | <td class="sig"> |
---|
585 | <a id="Date-getShortDayName"></a> |
---|
586 | <b>getShortDayName</b>( <code>Number day</code> ) : String <div class="mdesc"> |
---|
587 | <div class="short"><static> Get the short day name for the given day number. |
---|
588 | Override this function for international dates.</div> |
---|
589 | <div class="long"> |
---|
590 | <static> Get the short day name for the given day number. |
---|
591 | Override this function for international dates. <div class="mdetail-params"> |
---|
592 | <strong>Parameters:</strong> |
---|
593 | <ul><li><code>day</code> : Number<div class="sub-desc">A zero-based javascript day number.</div></li> </ul> |
---|
594 | <strong>Returns:</strong> |
---|
595 | <ul> |
---|
596 | <li><code>String</code><div class="sub-desc">The short day name.</div></li> |
---|
597 | </ul> |
---|
598 | </div> |
---|
599 | </div> |
---|
600 | </div> |
---|
601 | </td> |
---|
602 | <td class="msource">Date</td> |
---|
603 | </tr> |
---|
604 | <tr class="method-row alt expandable"> |
---|
605 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
606 | <td class="sig"> |
---|
607 | <a id="Date-getShortMonthName"></a> |
---|
608 | <b>getShortMonthName</b>( <code>Number month</code> ) : String <div class="mdesc"> |
---|
609 | <div class="short"><static> Get the short month name for the given month number. |
---|
610 | Override this function for international dates.</div> |
---|
611 | <div class="long"> |
---|
612 | <static> Get the short month name for the given month number. |
---|
613 | Override this function for international dates. <div class="mdetail-params"> |
---|
614 | <strong>Parameters:</strong> |
---|
615 | <ul><li><code>month</code> : Number<div class="sub-desc">A zero-based javascript month number.</div></li> </ul> |
---|
616 | <strong>Returns:</strong> |
---|
617 | <ul> |
---|
618 | <li><code>String</code><div class="sub-desc">The short month name.</div></li> |
---|
619 | </ul> |
---|
620 | </div> |
---|
621 | </div> |
---|
622 | </div> |
---|
623 | </td> |
---|
624 | <td class="msource">Date</td> |
---|
625 | </tr> |
---|
626 | <tr class="method-row expandable"> |
---|
627 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
628 | <td class="sig"> |
---|
629 | <a id="Date-getSuffix"></a> |
---|
630 | <b>getSuffix</b>() : String <div class="mdesc"> |
---|
631 | <div class="short">Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').</div> |
---|
632 | <div class="long"> |
---|
633 | Get the English ordinal suffix of the current day (equivalent to the format specifier 'S'). <div class="mdetail-params"> |
---|
634 | <strong>Parameters:</strong> |
---|
635 | <ul><li>None.</li> </ul> |
---|
636 | <strong>Returns:</strong> |
---|
637 | <ul> |
---|
638 | <li><code>String</code><div class="sub-desc">'st, 'nd', 'rd' or 'th'.</div></li> |
---|
639 | </ul> |
---|
640 | </div> |
---|
641 | </div> |
---|
642 | </div> |
---|
643 | </td> |
---|
644 | <td class="msource">Date</td> |
---|
645 | </tr> |
---|
646 | <tr class="method-row alt expandable"> |
---|
647 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
648 | <td class="sig"> |
---|
649 | <a id="Date-getTimezone"></a> |
---|
650 | <b>getTimezone</b>() : String <div class="mdesc"> |
---|
651 | <div class="short">Get the timezone abbreviation of the current date (equivalent to the format specifier 'T'). |
---|
652 | Note: The date string ret...</div> |
---|
653 | <div class="long"> |
---|
654 | Get the timezone abbreviation of the current date (equivalent to the format specifier 'T'). |
---|
655 | Note: The date string returned by the javascript Date object's toString() method varies |
---|
656 | between browsers (e.g. FF vs IE) and system region settings (e.g. IE in Asia vs IE in America). |
---|
657 | For a given date string e.g. "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)", |
---|
658 | getTimezone() first tries to get the timezone abbreviation from between a pair of parentheses |
---|
659 | (which may or may not be present), failing which it proceeds to get the timezone abbreviation |
---|
660 | from the GMT offset portion of the date string. <div class="mdetail-params"> |
---|
661 | <strong>Parameters:</strong> |
---|
662 | <ul><li>None.</li> </ul> |
---|
663 | <strong>Returns:</strong> |
---|
664 | <ul> |
---|
665 | <li><code>String</code><div class="sub-desc">The abbreviated timezone name (e.g. 'CST', 'PDT', 'EDT', 'MPST' ...).</div></li> |
---|
666 | </ul> |
---|
667 | </div> |
---|
668 | </div> |
---|
669 | </div> |
---|
670 | </td> |
---|
671 | <td class="msource">Date</td> |
---|
672 | </tr> |
---|
673 | <tr class="method-row expandable"> |
---|
674 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
675 | <td class="sig"> |
---|
676 | <a id="Date-getWeekOfYear"></a> |
---|
677 | <b>getWeekOfYear</b>() : Number <div class="mdesc"> |
---|
678 | <div class="short">Get the numeric ISO-8601 week number of the year. |
---|
679 | (equivalent to the format specifier 'W', but without a leading zero).</div> |
---|
680 | <div class="long"> |
---|
681 | Get the numeric ISO-8601 week number of the year. |
---|
682 | (equivalent to the format specifier 'W', but without a leading zero). <div class="mdetail-params"> |
---|
683 | <strong>Parameters:</strong> |
---|
684 | <ul><li>None.</li> </ul> |
---|
685 | <strong>Returns:</strong> |
---|
686 | <ul> |
---|
687 | <li><code>Number</code><div class="sub-desc">1 to 53</div></li> |
---|
688 | </ul> |
---|
689 | </div> |
---|
690 | </div> |
---|
691 | </div> |
---|
692 | </td> |
---|
693 | <td class="msource">Date</td> |
---|
694 | </tr> |
---|
695 | <tr class="method-row alt expandable"> |
---|
696 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
697 | <td class="sig"> |
---|
698 | <a id="Date-isLeapYear"></a> |
---|
699 | <b>isLeapYear</b>() : Boolean <div class="mdesc"> |
---|
700 | <div class="short">Whether or not the current date is in a leap year.</div> |
---|
701 | <div class="long"> |
---|
702 | Whether or not the current date is in a leap year. <div class="mdetail-params"> |
---|
703 | <strong>Parameters:</strong> |
---|
704 | <ul><li>None.</li> </ul> |
---|
705 | <strong>Returns:</strong> |
---|
706 | <ul> |
---|
707 | <li><code>Boolean</code><div class="sub-desc">True if the current date is in a leap year, else false.</div></li> |
---|
708 | </ul> |
---|
709 | </div> |
---|
710 | </div> |
---|
711 | </div> |
---|
712 | </td> |
---|
713 | <td class="msource">Date</td> |
---|
714 | </tr> |
---|
715 | <tr class="method-row expandable"> |
---|
716 | <td class="micon"><a class="exi" href="#expand"> </a></td> |
---|
717 | <td class="sig"> |
---|
718 | <a id="Date-parseDate"></a> |
---|
719 | <b>parseDate</b>( <code>String input</code>, <code>String format</code> ) : Date <div class="mdesc"> |
---|
720 | <div class="short"><static> Parses the passed string using the specified format. Note that this function expects dates in normal c...</div> |
---|
721 | <div class="long"> |
---|
722 | <static> Parses the passed string using the specified format. Note that this function expects dates in normal calendar |
---|
723 | format, meaning that months are 1-based (1 = January) and not zero-based like in JavaScript dates. Any part of |
---|
724 | the date format that is not specified will default to the current date value for that part. Time parts can also |
---|
725 | be specified, but default to 0. Keep in mind that the input date string must precisely match the specified format |
---|
726 | string or the parse operation will fail. |
---|
727 | Example Usage: |
---|
728 | <pre><code><i>//dt = Fri May 25 2007 (current date)</i> |
---|
729 | <b>var</b> dt = <b>new</b> Date(); |
---|
730 | |
---|
731 | <i>//dt = Thu May 25 2006 (today's month/day <b>in</b> 2006)</i> |
---|
732 | dt = Date.parseDate(<em>"2006"</em>, <em>"Y"</em>); |
---|
733 | |
---|
734 | <i>//dt = Sun Jan 15 2006 (all date parts specified)</i> |
---|
735 | dt = Date.parseDate(<em>"2006-01-15"</em>, <em>"Y-m-d"</em>); |
---|
736 | |
---|
737 | <i>//dt = Sun Jan 15 2006 15:20:01 GMT-0600 (CST)</i> |
---|
738 | dt = Date.parseDate(<em>"2006-01-15 3:20:01 PM"</em>, <em>"Y-m-d h:i:s A"</em> );</code></pre> <div class="mdetail-params"> |
---|
739 | <strong>Parameters:</strong> |
---|
740 | <ul><li><code>input</code> : String<div class="sub-desc">The unparsed date as a string.</div></li><li><code>format</code> : String<div class="sub-desc">The format the date is in.</div></li> </ul> |
---|
741 | <strong>Returns:</strong> |
---|
742 | <ul> |
---|
743 | <li><code>Date</code><div class="sub-desc">The parsed date.</div></li> |
---|
744 | </ul> |
---|
745 | </div> |
---|
746 | </div> |
---|
747 | </div> |
---|
748 | </td> |
---|
749 | <td class="msource">Date</td> |
---|
750 | </tr> |
---|
751 | </table> |
---|
752 | <a id="Date-events"></a> |
---|
753 | <h2>Public Events</h2> |
---|
754 | <div class="no-members">This class has no public events.</div> |
---|
755 | </div> |
---|