c8a9cac6a98710d607aa2c6e2c233a8e3c0c9ef9.svn-base 36 KB

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