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>
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>
15 <div class="description">
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
\r
22 ------ ----------------------------------------------------------------------- -----------------------
\r
23 d Day of the month, 2 digits with leading zeros 01 to 31
\r
24 D A short textual representation of the day of the week Mon to Sun
\r
25 j Day of the month without leading zeros 1 to 31
\r
26 l A full textual representation of the day of the week Sunday to Saturday
\r
27 N ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
\r
28 S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
\r
29 w Numeric representation of the day of the week 0 (for Sunday) to 6 (for Saturday)
\r
30 z The day of the year (starting from 0) 0 to 364 (365 in leap years)
\r
31 W ISO-8601 week number of year, weeks starting on Monday 01 to 53
\r
32 F A full textual representation of a month, such as January or March January to December
\r
33 m Numeric representation of a month, with leading zeros 01 to 12
\r
34 M A short textual representation of a month Jan to Dec
\r
35 n Numeric representation of a month, without leading zeros 1 to 12
\r
36 t Number of days in the given month 28 to 31
\r
37 L Whether it's a leap year 1 if it is a leap year, 0 otherwise.
\r
38 o ISO-8601 year number (identical to (Y), but if the ISO week number (W) Examples: 1998 or 2004
\r
39 belongs to the previous or next year, that year is used instead)
\r
40 Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
\r
41 y A two digit representation of a year Examples: 99 or 03
\r
42 a Lowercase Ante meridiem and Post meridiem am or pm
\r
43 A Uppercase Ante meridiem and Post meridiem AM or PM
\r
44 g 12-hour format of an hour without leading zeros 1 to 12
\r
45 G 24-hour format of an hour without leading zeros 0 to 23
\r
46 h 12-hour format of an hour with leading zeros 01 to 12
\r
47 H 24-hour format of an hour with leading zeros 00 to 23
\r
48 i Minutes, with leading zeros 00 to 59
\r
49 s Seconds, with leading zeros 00 to 59
\r
50 u Decimal fraction of a second Examples:
\r
51 (minimum 1 digit, arbitrary number of digits allowed) 001 (i.e. 0.001s) or
\r
52 100 (i.e. 0.100s) or
\r
53 999 (i.e. 0.999s) or
\r
54 999876543210 (i.e. 0.999876543210s)
\r
55 O Difference to Greenwich time (GMT) in hours and minutes Example: +1030
\r
56 P Difference to Greenwich time (GMT) with colon between hours and minutes Example: -08:00
\r
57 T Timezone abbreviation of the machine running the code Examples: EST, MDT, PDT ...
\r
58 Z Timezone offset in seconds (negative if west of UTC, positive if east) -43200 to 50400
\r
59 c ISO 8601 date (note: the decimal fraction of a second, if specified, Examples:
\r
60 must contain at least 1 digit. There is no limit on the maximum number 2007-04-17T15:19:21+08:00 or
\r
61 of digits allowed. see http://www.w3.org/TR/NOTE-datetime for more info) 2008-03-16T16:18:22Z or
\r
62 2009-02-15T17:17:23.9+01:00 or
\r
63 2010-01-14T18:16:24,999876543-07:00
\r
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>
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>
91 <pre><code>var dt = <b>new</b> Date();
92 document.write(dt.format(Date.patterns.ShortDate));</code></pre> </div>
94 <div class="hr"></div>
95 <a id="Date-props"></a>
96 <h2>Public Properties</h2>
97 <table cellspacing="0" class="member-table">
99 <th class="sig-header" colspan="2">Property</th>
100 <th class="msource-header">Defined By</th>
102 <tr class="property-row">
\r
103 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
105 <a id="Date-DAY"></a>
\r
106 <b>DAY</b> : String <div class="mdesc">
\r
107 <static> Date interval constant </div>
\r
109 <td class="msource">Date</td>
\r
111 <tr class="property-row alt">
\r
112 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
114 <a id="Date-HOUR"></a>
\r
115 <b>HOUR</b> : String <div class="mdesc">
\r
116 <static> Date interval constant </div>
\r
118 <td class="msource">Date</td>
\r
120 <tr class="property-row">
\r
121 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
123 <a id="Date-MILLI"></a>
\r
124 <b>MILLI</b> : String <div class="mdesc">
\r
125 <static> Date interval constant </div>
\r
127 <td class="msource">Date</td>
\r
129 <tr class="property-row alt">
\r
130 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
132 <a id="Date-MINUTE"></a>
\r
133 <b>MINUTE</b> : String <div class="mdesc">
\r
134 <static> Date interval constant </div>
\r
136 <td class="msource">Date</td>
\r
138 <tr class="property-row">
\r
139 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
141 <a id="Date-MONTH"></a>
\r
142 <b>MONTH</b> : String <div class="mdesc">
\r
143 <static> Date interval constant </div>
\r
145 <td class="msource">Date</td>
\r
147 <tr class="property-row alt">
\r
148 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
150 <a id="Date-SECOND"></a>
\r
151 <b>SECOND</b> : String <div class="mdesc">
\r
152 <static> Date interval constant </div>
\r
154 <td class="msource">Date</td>
\r
156 <tr class="property-row">
\r
157 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
159 <a id="Date-YEAR"></a>
\r
160 <b>YEAR</b> : String <div class="mdesc">
\r
161 <static> Date interval constant </div>
\r
163 <td class="msource">Date</td>
\r
165 <tr class="property-row alt expandable">
\r
166 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
168 <a id="Date-dayNames"></a>
\r
169 <b>dayNames</b> : Array <div class="mdesc">
\r
170 <div class="short"><static> An array of textual day names.
171 Override these values for international dates.
173 Date.dayNames =...</div>
\r
175 <static> An array of textual day names.
176 Override these values for international dates.
178 <pre><code>Date.dayNames = [
179 <em>'SundayInYourLang'</em>,
180 <em>'MondayInYourLang'</em>,
182 ];</code></pre> </div>
\r
185 <td class="msource">Date</td>
\r
187 <tr class="property-row expandable">
\r
188 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
190 <a id="Date-formatCodes"></a>
\r
191 <b>formatCodes</b> : Object <div class="mdesc">
\r
192 <div class="short"><static> The base format-code to formatting-function hashmap used by the format method.
193 Formatting functions ar...</div>
\r
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.
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>
\r
206 <td class="msource">Date</td>
\r
208 <tr class="property-row alt expandable">
\r
209 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
211 <a id="Date-monthNames"></a>
\r
212 <b>monthNames</b> : Array <div class="mdesc">
\r
213 <div class="short"><static> An array of textual month names.
214 Override these values for international dates.
216 Date.monthNam...</div>
\r
218 <static> An array of textual month names.
219 Override these values for international dates.
221 <pre><code>Date.monthNames = [
222 <em>'JanInYourLang'</em>,
223 <em>'FebInYourLang'</em>,
225 ];</code></pre> </div>
\r
228 <td class="msource">Date</td>
\r
230 <tr class="property-row expandable">
\r
231 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
233 <a id="Date-monthNumbers"></a>
\r
234 <b>monthNumbers</b> : Object <div class="mdesc">
\r
235 <div class="short"><static> An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are ...</div>
\r
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.
240 <pre><code>Date.monthNumbers = {
241 <em>'ShortJanNameInYourLang'</em>:0,
242 <em>'ShortFebNameInYourLang'</em>:1,
244 };</code></pre> </div>
\r
247 <td class="msource">Date</td>
\r
250 <a id="Date-methods"></a>
251 <h2>Public Methods</h2>
252 <table cellspacing="0" class="member-table">
254 <th class="sig-header" colspan="2">Method</th>
255 <th class="msource-header">Defined By</th>
257 <tr class="method-row expandable">
\r
258 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
260 <a id="Date-add"></a>
\r
261 <b>add</b>( <code>String interval</code>, <code>Number value</code> ) : Date <div class="mdesc">
\r
262 <div class="short">Provides a convenient method of performing basic date arithmetic. This method
263 does not modify the Date instance bein...</div>
\r
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.
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>
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>
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">
\r
280 <strong>Parameters:</strong>
\r
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>
\r
282 <strong>Returns:</strong>
\r
284 <li><code>Date</code><div class="sub-desc">The new Date instance.</div></li>
\r
290 <td class="msource">Date</td>
\r
292 <tr class="method-row alt expandable">
\r
293 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
295 <a id="Date-between"></a>
\r
296 <b>between</b>( <code>Date start</code>, <code>Date end</code> ) : Boolean <div class="mdesc">
\r
297 <div class="short">Checks if this date falls on or between the given start and end dates.</div>
\r
299 Checks if this date falls on or between the given start and end dates. <div class="mdetail-params">
\r
300 <strong>Parameters:</strong>
\r
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>
\r
302 <strong>Returns:</strong>
\r
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>
\r
310 <td class="msource">Date</td>
\r
312 <tr class="method-row expandable">
\r
313 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
315 <a id="Date-clearTime"></a>
\r
316 <b>clearTime</b>( <code>Boolean clone</code> ) : Date <div class="mdesc">
\r
317 <div class="short">Clears any time information from this date.</div>
\r
319 Clears any time information from this date. <div class="mdetail-params">
\r
320 <strong>Parameters:</strong>
\r
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>
\r
322 <strong>Returns:</strong>
\r
324 <li><code>Date</code><div class="sub-desc">this or the clone.</div></li>
\r
330 <td class="msource">Date</td>
\r
332 <tr class="method-row alt expandable">
\r
333 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
335 <a id="Date-clone"></a>
\r
336 <b>clone</b>() : Date <div class="mdesc">
\r
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>
\r
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;
349 document.write(orig); <i>//returns <em>'Thu Oct 05 2006'</em>!</i>
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();
355 document.write(orig); //returns <em>'Thu Oct 01 2006'</em></code></pre> <div class="mdetail-params">
\r
356 <strong>Parameters:</strong>
\r
357 <ul><li>None.</li> </ul>
\r
358 <strong>Returns:</strong>
\r
360 <li><code>Date</code><div class="sub-desc">The new Date instance.</div></li>
\r
366 <td class="msource">Date</td>
\r
368 <tr class="method-row expandable">
\r
369 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
371 <a id="Date-format"></a>
\r
372 <b>format</b>( <code>String format</code> ) : String <div class="mdesc">
\r
373 <div class="short">Formats a date given the supplied format string.</div>
\r
375 Formats a date given the supplied format string. <div class="mdetail-params">
\r
376 <strong>Parameters:</strong>
\r
377 <ul><li><code>format</code> : String<div class="sub-desc">The format string.</div></li> </ul>
\r
378 <strong>Returns:</strong>
\r
380 <li><code>String</code><div class="sub-desc">The formatted date.</div></li>
\r
386 <td class="msource">Date</td>
\r
388 <tr class="method-row alt expandable">
\r
389 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
391 <a id="Date-getDayOfYear"></a>
\r
392 <b>getDayOfYear</b>() : Number <div class="mdesc">
\r
393 <div class="short">Get the numeric day number of the year, adjusted for leap year.</div>
\r
395 Get the numeric day number of the year, adjusted for leap year. <div class="mdetail-params">
\r
396 <strong>Parameters:</strong>
\r
397 <ul><li>None.</li> </ul>
\r
398 <strong>Returns:</strong>
\r
400 <li><code>Number</code><div class="sub-desc">0 to 364 (365 in leap years).</div></li>
\r
406 <td class="msource">Date</td>
\r
408 <tr class="method-row expandable">
\r
409 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
411 <a id="Date-getDaysInMonth"></a>
\r
412 <b>getDaysInMonth</b>() : Number <div class="mdesc">
\r
413 <div class="short">Get the number of days in the current month, adjusted for leap year.</div>
\r
415 Get the number of days in the current month, adjusted for leap year. <div class="mdetail-params">
\r
416 <strong>Parameters:</strong>
\r
417 <ul><li>None.</li> </ul>
\r
418 <strong>Returns:</strong>
\r
420 <li><code>Number</code><div class="sub-desc">The number of days in the month.</div></li>
\r
426 <td class="msource">Date</td>
\r
428 <tr class="method-row alt expandable">
\r
429 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
431 <a id="Date-getElapsed"></a>
\r
432 <b>getElapsed</b>( <span class="optional" title="Optional">[<code>Date date</code>]</span> ) : Number <div class="mdesc">
\r
433 <div class="short">Returns the number of milliseconds between this date and date</div>
\r
435 Returns the number of milliseconds between this date and date <div class="mdetail-params">
\r
436 <strong>Parameters:</strong>
\r
437 <ul><li><code>date</code> : Date<div class="sub-desc">(optional) Defaults to now</div></li> </ul>
\r
438 <strong>Returns:</strong>
\r
440 <li><code>Number</code><div class="sub-desc">The diff in milliseconds</div></li>
\r
446 <td class="msource">Date</td>
\r
448 <tr class="method-row expandable">
\r
449 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
451 <a id="Date-getFirstDateOfMonth"></a>
\r
452 <b>getFirstDateOfMonth</b>() : Date <div class="mdesc">
\r
453 <div class="short">Get the date of the first day of the month in which this date resides.</div>
\r
455 Get the date of the first day of the month in which this date resides. <div class="mdetail-params">
\r
456 <strong>Parameters:</strong>
\r
457 <ul><li>None.</li> </ul>
\r
458 <strong>Returns:</strong>
\r
460 <li><code>Date</code></li>
\r
466 <td class="msource">Date</td>
\r
468 <tr class="method-row alt expandable">
\r
469 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
471 <a id="Date-getFirstDayOfMonth"></a>
\r
472 <b>getFirstDayOfMonth</b>() : Number <div class="mdesc">
\r
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>
\r
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.
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">
\r
482 <strong>Parameters:</strong>
\r
483 <ul><li>None.</li> </ul>
\r
484 <strong>Returns:</strong>
\r
486 <li><code>Number</code><div class="sub-desc">The day number (0-6).</div></li>
\r
492 <td class="msource">Date</td>
\r
494 <tr class="method-row expandable">
\r
495 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
497 <a id="Date-getGMTOffset"></a>
\r
498 <b>getGMTOffset</b>( <code>Boolean colon</code> ) : String <div class="mdesc">
\r
499 <div class="short">Get the offset from GMT of the current date (equivalent to the format specifier 'O').</div>
\r
501 Get the offset from GMT of the current date (equivalent to the format specifier 'O'). <div class="mdetail-params">
\r
502 <strong>Parameters:</strong>
\r
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>
\r
504 <strong>Returns:</strong>
\r
506 <li><code>String</code><div class="sub-desc">The 4-character offset string prefixed with + or - (e.g. '-0600').</div></li>
\r
512 <td class="msource">Date</td>
\r
514 <tr class="method-row alt expandable">
\r
515 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
517 <a id="Date-getLastDateOfMonth"></a>
\r
518 <b>getLastDateOfMonth</b>() : Date <div class="mdesc">
\r
519 <div class="short">Get the date of the last day of the month in which this date resides.</div>
\r
521 Get the date of the last day of the month in which this date resides. <div class="mdetail-params">
\r
522 <strong>Parameters:</strong>
\r
523 <ul><li>None.</li> </ul>
\r
524 <strong>Returns:</strong>
\r
526 <li><code>Date</code></li>
\r
532 <td class="msource">Date</td>
\r
534 <tr class="method-row expandable">
\r
535 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
537 <a id="Date-getLastDayOfMonth"></a>
\r
538 <b>getLastDayOfMonth</b>() : Number <div class="mdesc">
\r
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>
\r
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.
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">
\r
548 <strong>Parameters:</strong>
\r
549 <ul><li>None.</li> </ul>
\r
550 <strong>Returns:</strong>
\r
552 <li><code>Number</code><div class="sub-desc">The day number (0-6).</div></li>
\r
558 <td class="msource">Date</td>
\r
560 <tr class="method-row alt expandable">
\r
561 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
563 <a id="Date-getMonthNumber"></a>
\r
564 <b>getMonthNumber</b>( <code>String name</code> ) : Number <div class="mdesc">
\r
565 <div class="short"><static> Get the zero-based javascript month number for the given short/full month name.
566 Override this function...</div>
\r
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">
\r
570 <strong>Parameters:</strong>
\r
571 <ul><li><code>name</code> : String<div class="sub-desc">The short/full month name.</div></li> </ul>
\r
572 <strong>Returns:</strong>
\r
574 <li><code>Number</code><div class="sub-desc">The zero-based javascript month number.</div></li>
\r
580 <td class="msource">Date</td>
\r
582 <tr class="method-row expandable">
\r
583 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
585 <a id="Date-getShortDayName"></a>
\r
586 <b>getShortDayName</b>( <code>Number day</code> ) : String <div class="mdesc">
\r
587 <div class="short"><static> Get the short day name for the given day number.
588 Override this function for international dates.</div>
\r
590 <static> Get the short day name for the given day number.
591 Override this function for international dates. <div class="mdetail-params">
\r
592 <strong>Parameters:</strong>
\r
593 <ul><li><code>day</code> : Number<div class="sub-desc">A zero-based javascript day number.</div></li> </ul>
\r
594 <strong>Returns:</strong>
\r
596 <li><code>String</code><div class="sub-desc">The short day name.</div></li>
\r
602 <td class="msource">Date</td>
\r
604 <tr class="method-row alt expandable">
\r
605 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
607 <a id="Date-getShortMonthName"></a>
\r
608 <b>getShortMonthName</b>( <code>Number month</code> ) : String <div class="mdesc">
\r
609 <div class="short"><static> Get the short month name for the given month number.
610 Override this function for international dates.</div>
\r
612 <static> Get the short month name for the given month number.
613 Override this function for international dates. <div class="mdetail-params">
\r
614 <strong>Parameters:</strong>
\r
615 <ul><li><code>month</code> : Number<div class="sub-desc">A zero-based javascript month number.</div></li> </ul>
\r
616 <strong>Returns:</strong>
\r
618 <li><code>String</code><div class="sub-desc">The short month name.</div></li>
\r
624 <td class="msource">Date</td>
\r
626 <tr class="method-row expandable">
\r
627 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
629 <a id="Date-getSuffix"></a>
\r
630 <b>getSuffix</b>() : String <div class="mdesc">
\r
631 <div class="short">Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').</div>
\r
633 Get the English ordinal suffix of the current day (equivalent to the format specifier 'S'). <div class="mdetail-params">
\r
634 <strong>Parameters:</strong>
\r
635 <ul><li>None.</li> </ul>
\r
636 <strong>Returns:</strong>
\r
638 <li><code>String</code><div class="sub-desc">'st, 'nd', 'rd' or 'th'.</div></li>
\r
644 <td class="msource">Date</td>
\r
646 <tr class="method-row alt expandable">
\r
647 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
649 <a id="Date-getTimezone"></a>
\r
650 <b>getTimezone</b>() : String <div class="mdesc">
\r
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>
\r
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">
\r
661 <strong>Parameters:</strong>
\r
662 <ul><li>None.</li> </ul>
\r
663 <strong>Returns:</strong>
\r
665 <li><code>String</code><div class="sub-desc">The abbreviated timezone name (e.g. 'CST', 'PDT', 'EDT', 'MPST' ...).</div></li>
\r
671 <td class="msource">Date</td>
\r
673 <tr class="method-row expandable">
\r
674 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
676 <a id="Date-getWeekOfYear"></a>
\r
677 <b>getWeekOfYear</b>() : Number <div class="mdesc">
\r
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>
\r
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">
\r
683 <strong>Parameters:</strong>
\r
684 <ul><li>None.</li> </ul>
\r
685 <strong>Returns:</strong>
\r
687 <li><code>Number</code><div class="sub-desc">1 to 53</div></li>
\r
693 <td class="msource">Date</td>
\r
695 <tr class="method-row alt expandable">
\r
696 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
698 <a id="Date-isLeapYear"></a>
\r
699 <b>isLeapYear</b>() : Boolean <div class="mdesc">
\r
700 <div class="short">Whether or not the current date is in a leap year.</div>
\r
702 Whether or not the current date is in a leap year. <div class="mdetail-params">
\r
703 <strong>Parameters:</strong>
\r
704 <ul><li>None.</li> </ul>
\r
705 <strong>Returns:</strong>
\r
707 <li><code>Boolean</code><div class="sub-desc">True if the current date is in a leap year, else false.</div></li>
\r
713 <td class="msource">Date</td>
\r
715 <tr class="method-row expandable">
\r
716 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
718 <a id="Date-parseDate"></a>
\r
719 <b>parseDate</b>( <code>String input</code>, <code>String format</code> ) : Date <div class="mdesc">
\r
720 <div class="short"><static> Parses the passed string using the specified format. Note that this function expects dates in normal c...</div>
\r
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.
728 <pre><code><i>//dt = Fri May 25 2007 (current date)</i>
729 <b>var</b> dt = <b>new</b> Date();
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>);
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>);
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">
\r
739 <strong>Parameters:</strong>
\r
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>
\r
741 <strong>Returns:</strong>
\r
743 <li><code>Date</code><div class="sub-desc">The parsed date.</div></li>
\r
749 <td class="msource">Date</td>
\r
752 <a id="Date-events"></a>
753 <h2>Public Events</h2>
754 <div class="no-members">This class has no public events.</div>