4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Date'>/**
21 * Creates `Date` instances which let you work with dates and times.
23 * If you supply no arguments, the constructor creates a `Date` object for today's
24 * date and time according to local time. If you supply some arguments but not
25 * others, the missing arguments are set to 0. If you supply any arguments, you
26 * must supply at least the year, month, and day. You can omit the hours, minutes,
27 * seconds, and milliseconds.
29 * The date is measured in milliseconds since midnight 01 January, 1970 UTC. A day
30 * holds 86,400,000 milliseconds. The `Date` object range is -100,000,000 days to
31 * 100,000,000 days relative to 01 January, 1970 UTC.
33 * The `Date` object provides uniform behavior across platforms.
35 * The `Date` object supports a number of UTC (universal) methods, as well as
36 * local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the
37 * time as set by the World Time Standard. The local time is the time known to the
38 * computer where JavaScript is executed.
40 * Invoking `Date` in a non-constructor context (i.e., without the `new` operator)
41 * will return a string representing the current time.
43 * Note that `Date` objects can only be instantiated by calling `Date` or using it
44 * as a constructor; unlike other JavaScript object types, `Date` objects have no
47 * # Several ways to assign dates
49 * The following example shows several ways to assign dates:
52 * birthday = new Date("December 19, 1989 03:24:00");
53 * birthday = new Date(1989,11,19);
54 * birthday = new Date(1989,11,17,3,24,0);
56 * # Calculating elapsed time
58 * The following examples show how to determine the elapsed time between two dates:
60 * // using static methods
61 * var start = Date.now();
62 * // the event you'd like to time goes here:
63 * doSomethingForALongTime();
64 * var end = Date.now();
65 * var elapsed = end - start; // time in milliseconds
67 * // if you have Date objects
68 * var start = new Date();
69 * // the event you'd like to time goes here:
70 * doSomethingForALongTime();
71 * var end = new Date();
72 * var elapsed = end.getTime() - start.getTime(); // time in milliseconds
74 * // if you want to test a function and get back its return
75 * function printElapsedTime (fTest) {
76 * var nStartTime = Date.now(), vReturn = fTest(), nEndTime = Date.now();
77 * alert("Elapsed time: " + String(nEndTime - nStartTime) + "
78 * milliseconds");
82 * yourFunctionReturn = printElapsedTime(yourFunction);
84 * # ISO 8601 formatted dates
86 * The following example shows how to formate a date in an ISO 8601 format using
89 * // use a function for the exact format desired...
90 * function ISODateString(d){
91 * function pad(n){return n<10 ? '0'+n : n}
92 * return d.getUTCFullYear()+'-'
93 * + pad(d.getUTCMonth()+1)+'-'
94 * + pad(d.getUTCDate())+'T'
95 * + pad(d.getUTCHours())+':'
96 * + pad(d.getUTCMinutes())+':'
97 * + pad(d.getUTCSeconds())+'Z'}
100 * print(ISODateString(d)); // prints something like 2009-09-28T19:03:12Z
102 * <div class="notice">
103 * Documentation for this class comes from <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date">MDN</a>
104 * and is available under <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons: Attribution-Sharealike license</a>.
108 <span id='Date-method-constructor'>/**
109 </span> * @method constructor
110 * Creates new Date object.
112 * @param {Number/String} [year]
113 * Either UNIX timestamp, date string, or year (when month and day parameters also provided):
115 * - Integer value representing the number of milliseconds since 1 January 1970
116 * 00:00:00 UTC (Unix Epoch).
118 * - String value representing a date. The string should be in a format recognized
119 * by the parse method (IETF-compliant RFC 1123 timestamps).
121 * - Integer value representing the year. For compatibility (in order to avoid the
122 * Y2K problem), you should always specify the year in full; use 1998, rather
125 * @param {Number} [month]
126 * Integer value representing the month, beginning with 0 for January to 11
128 * @param {Number} [day]
129 * Integer value representing the day of the month (1-31).
130 * @param {Number} [hour]
131 * Integer value representing the hour of the day (0-23).
132 * @param {Number} [minute]
133 * Integer value representing the minute segment (0-59) of a time reading.
134 * @param {Number} [second]
135 * Integer value representing the second segment (0-59) of a time reading.
136 * @param {Number} [millisecond]
137 * Integer value representing the millisecond segment (0-999) of a time reading.
143 <span id='Date-static-method-now'>/**
144 </span> * @method now
146 * Returns the numeric value corresponding to the current time.
148 * The `now` method returns the milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now as
151 * When using `now` to create timestamps or unique IDs, keep in mind that the resolution may be 15
152 * milliseconds on Windows, so you could end up with several equal values if `now` is called multiple
153 * times within a short time span.
155 * @return {Number} Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
158 <span id='Date-static-method-parse'>/**
159 </span> * @method parse
161 * Parses a string representation of a date, and returns the number of milliseconds
162 * since January 1, 1970, 00:00:00, local time.
164 * The `parse` method takes a date string (such as `"Dec 25, 1995"`) and returns the number of
165 * milliseconds since January 1, 1970, 00:00:00 UTC. The local time zone is used to interpret
166 * arguments that do not contain time zone information. This function is useful for setting date
167 * values based on string values, for example in conjunction with the `setTime` method and the
168 * {@link Date} object.
170 * Given a string representing a time, parse returns the time value. It accepts the IETF standard (RFC
171 * 1123 Section 5.2.14 and elsewhere) date syntax: `"Mon, 25 Dec 1995 13:30:00 GMT"`. It understands
172 * the continental US time-zone abbreviations, but for general use, use a time-zone offset, for
173 * example, `"Mon, 25 Dec 1995 13:30:00 GMT+0430"` (4 hours, 30 minutes east of the Greenwich
174 * meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are
175 * considered equivalent.
179 * If `IPOdate` is an existing `Date` object, then you can set it to August 9, 1995 (local time) as
182 * IPOdate.setTime(Date.parse("Aug 9, 1995"));
184 * Some other examples:
186 * // Returns 807937200000 in time zone GMT-0300, and other values in other
187 * // timezones, since the argument does not specify a time zone.
188 * Date.parse("Aug 9, 1995");
190 * // Returns 807926400000 no matter the local time zone.
191 * Date.parse("Wed, 09 Aug 1995 00:00:00 GMT");
193 * // Returns 807937200000 in timezone GMT-0300, and other values in other
194 * // timezones, since there is no time zone specifier in the argument.
195 * Date.parse("Wed, 09 Aug 1995 00:00:00");
197 * // Returns 0 no matter the local time zone.
198 * Date.parse("Thu, 01 Jan 1970 00:00:00 GMT");
200 * // Returns 14400000 in timezone GMT-0400, and other values in other
201 * // timezones, since there is no time zone specifier in the argument.
202 * Date.parse("Thu, 01 Jan 1970 00:00:00");
204 * // Returns 14400000 no matter the local time zone.
205 * Date.parse("Thu, 01 Jan 1970 00:00:00 GMT-0400");
207 * @param {String} dateString A string representing a date.
208 * @return {Number} Number of milliseconds since January 1, 1970, 00:00:00, local time.
211 <span id='Date-static-method-UTC'>/**
212 </span> * @method UTC
214 * Accepts the same parameters as the longest form of the constructor, and returns
215 * the number of milliseconds in a `Date` object since January 1, 1970, 00:00:00,
218 * `UTC` takes comma-delimited date parameters and returns the number of milliseconds between January
219 * 1, 1970, 00:00:00, universal time and the time you specified.
221 * You should specify a full year for the year; for example, 1998. If a year between 0 and 99 is
222 * specified, the method converts the year to a year in the 20th century (1900 + year); for example,
223 * if you specify 95, the year 1995 is used.
225 * The `UTC` method differs from the `Date` constructor in two ways.
226 * * `Date.UTC` uses universal time instead of the local time.
227 * * `Date.UTC` returns a time value as a number instead of creating a `Date` object.
229 * If a parameter you specify is outside of the expected range, the `UTC` method updates the other
230 * parameters to allow for your number. For example, if you use 15 for month, the year will be
231 * incremented by 1 (year + 1), and 3 will be used for the month.
233 * Because `UTC` is a static method of `Date`, you always use it as `Date.UTC()`, rather than as a
234 * method of a `Date` object you created.
236 * The following statement creates a `Date` object using GMT instead of local time:
238 * gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0));
240 * @param {Number} year A year after 1900.
241 * @param {Number} month An integer between 0 and 11 representing the month.
242 * @param {Number} date An integer between 1 and 31 representing the day of the month.
243 * @param {Number} hrs An integer between 0 and 23 representing the hours.
244 * @param {Number} min An integer between 0 and 59 representing the minutes.
245 * @param {Number} sec An integer between 0 and 59 representing the seconds.
246 * @param {Number} ms An integer between 0 and 999 representing the milliseconds.
247 * @return {Date} Number of milliseconds since January 1, 1970, 00:00:00, universal time.
252 <span id='Date-method-getDate'>/**
253 </span> * @method getDate
254 * Returns the numeric value corresponding to the current time.
256 * The second statement below assigns the value 25 to the variable `day`, based on the value of the
257 * `Date` object `Xmas95`.
259 * Xmas95 = new Date("December 25, 1995 23:15:00")
260 * day = Xmas95.getDate()
262 * @return {Number} Value between 1 and 31.
265 <span id='Date-method-getDay'>/**
266 </span> * @method getDay
267 * Returns the numeric value corresponding to the current time.
269 * The value returned by `getDay` is an integer corresponding to the day of the week: 0 for Sunday, 1
270 * for Monday, 2 for Tuesday, and so on.
272 * The second statement below assigns the value 1 to `weekday`, based on the value of the `Date`
273 * object `Xmas95`. December 25, 1995, is a Monday.
275 * Xmas95 = new Date("December 25, 1995 23:15:00");
276 * weekday = Xmas95.getDay();
278 * @return {Number} A numeric representation of the day from Sunday (0) to
282 <span id='Date-method-getFullYear'>/**
283 </span> * @method getFullYear
284 * Returns the numeric value corresponding to the current time.
286 * The value returned by `getFullYear` is an absolute number. For dates between the years 1000 and
287 * 9999, `getFullYear` returns a four-digit number, for example, 1995. Use this function to make sure
288 * a year is compliant with years after 2000.
290 * Use this method instead of the `getYear` method.
292 * The following example assigns the four-digit value of the current year to the variable yr.
294 * var today = new Date();
295 * var yr = today.getFullYear();
297 * @return {Number} Four digit representation of the year.
300 <span id='Date-method-getHours'>/**
301 </span> * @method getHours
302 * Returns the numeric value corresponding to the current time.
304 * The second statement below assigns the value 23 to the variable `hours`, based on the value of the
305 * `Date` object `Xmas95`.
307 * Xmas95 = new Date("December 25, 1995 23:15:00")
308 * hours = Xmas95.getHours()
310 * @return {Number} Value between 0 and 23, using 24-hour clock.
313 <span id='Date-method-getMilliseconds'>/**
314 </span> * @method getMilliseconds
315 * Returns the numeric value corresponding to the current time.
317 * The following example assigns the milliseconds portion of the current time to the variable ms.
320 * Today = new Date();
321 * ms = Today.getMilliseconds();
323 * @return {Number} A number between 0 and 999.
326 <span id='Date-method-getMinutes'>/**
327 </span> * @method getMinutes
328 * Returns the numeric value corresponding to the current time.
330 * The second statement below assigns the value 15 to the variable `minutes`, based on the value of
331 * the `Date` object `Xmas95`.
333 * Xmas95 = new Date("December 25, 1995 23:15:00")
334 * minutes = Xmas95.getMinutes()
336 * @return {Number} Value between 0 and 59.
339 <span id='Date-method-getMonth'>/**
340 </span> * @method getMonth
341 * Returns the numeric value corresponding to the current time.
343 * The second statement below assigns the value 11 to the variable `month`, based on the value of the
344 * `Date` object `Xmas95`.
346 * Xmas95 = new Date("December 25, 1995 23:15:00")
347 * month = Xmas95.getMonth()
349 * @return {Number} An integer between 0 and 11. 0 corresponds to January, 1 to February, and so on.
352 <span id='Date-method-getSeconds'>/**
353 </span> * @method getSeconds
354 * Returns the numeric value corresponding to the current time.
356 * The second statement below assigns the value 30 to the variable `secs`, based on the value of the
357 * `Date` object `Xmas95`.
359 * Xmas95 = new Date("December 25, 1995 23:15:30")
360 * secs = Xmas95.getSeconds()
362 * @return {Number} Value between 0 and 59.
365 <span id='Date-method-getTime'>/**
366 </span> * @method getTime
367 * Returns the numeric value corresponding to the current time.
369 * The value returned by the `getTime` method is the number of milliseconds since 1 January 1970
370 * 00:00:00 UTC. You can use this method to help assign a date and time to another `Date` object.
372 * This method is functionally equivalent to the `valueOf` method.
374 * Using getTime for copying dates
376 * Constructing a date object with the identical time value.
378 * var birthday = new Date(1994, 12, 10);
379 * var copy = new Date();
380 * copy.setTime(birthday.getTime());
382 * Measuring execution time
384 * Subtracting two subsequent getTime calls on newly generated Date objects, give the time span
385 * between these two calls. This can be used to calculate the executing time of some operations.
389 * start = new Date();
390 * for (var i = 0; i < 1000; i++)
394 * console.log("Operation took " + (end.getTime() - start.getTime()) + " msec");
396 * @return {Number} Number of milliseconds since 1/1/1970 (GMT).
399 <span id='Date-method-getTimezoneOffset'>/**
400 </span> * @method getTimezoneOffset
401 * Returns the numeric value corresponding to the current time.
403 * The time-zone offset is the difference, in minutes, between UTC and local time. Note that this
404 * means that the offset is positive if the local timezone is behind UTC and negative if it is ahead.
405 * For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned.
406 * Daylight savings time prevents this value from being a constant even for a given locale
409 * currentTimeZoneOffsetInHours = x.getTimezoneOffset()/60
411 * @return {Number} Minutes between GMT and local time.
414 <span id='Date-method-getUTCDate'>/**
415 </span> * @method getUTCDate
416 * Returns the numeric value corresponding to the current time.
418 * The following example assigns the day portion of the current date to the variable `d`.
421 * Today = new Date();
422 * d = Today.getUTCDate();
424 * @return {Number} Integer between 1 and 31 representing the day.
427 <span id='Date-method-getUTCDay'>/**
428 </span> * @method getUTCDay
429 * Returns the numeric value corresponding to the current time.
431 * The following example assigns the weekday portion of the current date to the variable `weekday`.
435 * weekday = Today.getUTCDay()
437 * @return {Number} A numeric representation of the day from Sunday (0) to
441 <span id='Date-method-getUTCFullYear'>/**
442 </span> * @method getUTCFullYear
443 * Returns the numeric value corresponding to the current time.
445 * The following example assigns the four-digit value of the current year to the variable `yr`.
448 * Today = new Date();
449 * yr = Today.getUTCFullYear();
451 * @return {Number} Four digit representation of the year.
454 <span id='Date-method-getUTCHours'>/**
455 </span> * @method getUTCHours
456 * Returns the numeric value corresponding to the current time.
458 * The following example assigns the hours portion of the current time to the variable `hrs`.
461 * Today = new Date();
462 * hrs = Today.getUTCHours();
464 * @return {Number} Value between 0 and 23.
467 <span id='Date-method-getUTCMilliseconds'>/**
468 </span> * @method getUTCMilliseconds
469 * Returns the numeric value corresponding to the current time.
471 * The following example assigns the milliseconds portion of the current time to the variable `ms`.
474 * Today = new Date();
475 * ms = Today.getUTCMilliseconds();
477 * @return {Number} Milliseconds portion of the Date.
480 <span id='Date-method-getUTCMinutes'>/**
481 </span> * @method getUTCMinutes
482 * Returns the numeric value corresponding to the current time.
484 * The following example assigns the minutes portion of the current time to the variable `min`.
487 * Today = new Date();
488 * min = Today.getUTCMinutes();
490 * @return {Number} Value between 0 and 59.
493 <span id='Date-method-getUTCMonth'>/**
494 </span> * @method getUTCMonth
495 * Returns the numeric value corresponding to the current time.
497 * The following example assigns the month portion of the current date to the variable `mon`.
500 * Today = new Date();
501 * mon = Today.getUTCMonth();
503 * @return {Number} Value between 0 (January) and 11 (December).
506 <span id='Date-method-getUTCSeconds'>/**
507 </span> * @method getUTCSeconds
508 * Returns the numeric value corresponding to the current time.
510 * The following example assigns the seconds portion of the current time to the variable `sec`.
513 * Today = new Date();
514 * sec = Today.getUTCSeconds();
516 * @return {Number} Value between 0 and 59.
519 <span id='Date-method-setDate'>/**
520 </span> * @method setDate
521 * Sets the day of the month (1-31) for a specified date according to local time.
523 * If the parameter you specify is outside of the expected range, `setDate` attempts to update the
524 * date information in the `Date` object accordingly. For example, if you use 0 for `dayValue`, the
525 * date will be set to the last day of the previous month.
527 * The second statement below changes the day for theBigDay to July 24 from its original value.
529 * theBigDay = new Date("July 27, 1962 23:30:00")
530 * theBigDay.setDate(24)
532 * @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
533 * @return {Number} New date represented as milliseconds.
536 <span id='Date-method-setFullYear'>/**
537 </span> * @method setFullYear
538 * Sets the full year (4 digits for 4-digit years) for a specified date according to
541 * If you do not specify the `monthValue` and `dayValue` parameters, the values returned from the
542 * `getMonth` and `getDate` methods are used.
544 * If a parameter you specify is outside of the expected range, `setFullYear` attempts to update the
545 * other parameters and the date information in the `Date` object accordingly. For example, if you
546 * specify 15 for monthValue, the year is incremented by 1 (year + 1), and 3 is used for the month.
548 * theBigDay = new Date();
549 * theBigDay.setFullYear(1997);
551 * @param {Number} yearValue An integer specifying the numeric value of the year, for example, 1995.
552 * @param {Number} monthValue An integer between 0 and 11 representing the months January through
554 * @param {Number} dayValue An integer between 1 and 31 representing the day of the month. If you
555 * specify the `dayValue` parameter, you must also specify the `monthValue`.
556 * @return {Number} New date represented as milliseconds.
559 <span id='Date-method-setHours'>/**
560 </span> * @method setHours
561 * Sets the hours (0-23) for a specified date according to local time.
563 * If you do not specify the `minutesValue`, `secondsValue`, and `msValue` parameters, the values
564 * returned from the `getUTCMinutes`, `getUTCSeconds`, and `getMilliseconds` methods are used.
566 * If a parameter you specify is outside of the expected range, setHours attempts to update the date
567 * information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, the
568 * minutes will be incremented by 1 (min + 1), and 40 will be used for seconds.
570 * theBigDay.setHours(7)
572 * @param {Number} hoursValue An integer between 0 and 23, representing the hour.
573 * @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
574 * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the
575 * `secondsValue` parameter, you must also specify the `minutesValue`.
576 * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the
577 * `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
578 * @return {Number} New date represented as milliseconds.
581 <span id='Date-method-setMilliseconds'>/**
582 </span> * @method setMilliseconds
583 * Sets the milliseconds (0-999) for a specified date according to local time.
585 * If you specify a number outside the expected range, the date information in the `Date` object is
586 * updated accordingly. For example, if you specify 1005, the number of seconds is incremented by 1,
587 * and 5 is used for the milliseconds.
589 * theBigDay = new Date();
590 * theBigDay.setMilliseconds(100);
592 * @param {Number} millisecondsValue A number between 0 and 999, representing the milliseconds.
593 * @return {Number} New date represented as milliseconds.
596 <span id='Date-method-setMinutes'>/**
597 </span> * @method setMinutes
598 * Sets the minutes (0-59) for a specified date according to local time.
600 * If you do not specify the `secondsValue` and `msValue` parameters, the values returned from
601 * `getSeconds` and `getMilliseconds` methods are used.
603 * If a parameter you specify is outside of the expected range, `setMinutes` attempts to update the
604 * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
605 * the minutes (`minutesValue`) will be incremented by 1 (minutesValue + 1), and 40 will be used for
608 * theBigDay.setMinutes(45)
610 * @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
611 * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you
612 * specify the secondsValue parameter, you must also specify the `minutesValue`.
613 * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify
614 * the `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
615 * @return {Number} New date represented as milliseconds.
618 <span id='Date-method-setMonth'>/**
619 </span> * @method setMonth
620 * Sets the month (0-11) for a specified date according to local time.
622 * If you do not specify the `dayValue` parameter, the value returned from the `getDate` method is
625 * If a parameter you specify is outside of the expected range, `setMonth` attempts to update the date
626 * information in the `Date` object accordingly. For example, if you use 15 for `monthValue`, the year
627 * will be incremented by 1 (year + 1), and 3 will be used for month.
629 * theBigDay.setMonth(6)
631 * @param {Number} monthValue An integer between 0 and 11 (representing the months January through
633 * @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
634 * @return {Number} New date represented as milliseconds.
637 <span id='Date-method-setSeconds'>/**
638 </span> * @method setSeconds
639 * Sets the seconds (0-59) for a specified date according to local time.
641 * If you do not specify the `msValue` parameter, the value returned from the `getMilliseconds` method
644 * If a parameter you specify is outside of the expected range, `setSeconds` attempts to update the
645 * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
646 * the minutes stored in the `Date` object will be incremented by 1, and 40 will be used for seconds.
648 * theBigDay.setSeconds(30)
650 * @param {Number} secondsValue An integer between 0 and 59.
651 * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify
652 * the`msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
653 * @return {Number} New date represented as milliseconds.
656 <span id='Date-method-setTime'>/**
657 </span> * @method setTime
658 * Sets the Date object to the time represented by a number of milliseconds since
659 * January 1, 1970, 00:00:00 UTC, allowing for negative numbers for times prior.
661 * Use the `setTime` method to help assign a date and time to another `Date` object.
663 * theBigDay = new Date("July 1, 1999")
664 * sameAsBigDay = new Date()
665 * sameAsBigDay.setTime(theBigDay.getTime())
667 * @param {Number} timeValue An integer representing the number of milliseconds since 1 January
668 * 1970, 00:00:00 UTC.
669 * @return {Number} New date represented as milliseconds.
672 <span id='Date-method-setUTCDate'>/**
673 </span> * @method setUTCDate
674 * Sets the day of the month (1-31) for a specified date according to universal time.
676 * If a parameter you specify is outside of the expected range, `setUTCDate` attempts to update the
677 * date information in the `Date` object accordingly. For example, if you use 40 for `dayValue`, and
678 * the month stored in the `Date` object is June, the day will be changed to 10 and the month will be
679 * incremented to July.
681 * theBigDay = new Date();
682 * theBigDay.setUTCDate(20);
684 * @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
685 * @return {Number} New date represented as milliseconds.
688 <span id='Date-method-setUTCFullYear'>/**
689 </span> * @method setUTCFullYear
690 * Sets the full year (4 digits for 4-digit years) for a specified date according
693 * If you do not specify the `monthValue` and `dayValue` parameters, the values returned from the
694 * `getMonth` and `getDate` methods are used.
696 * If a parameter you specify is outside of the expected range, `setUTCFullYear` attempts to update
697 * the other parameters and the date information in the `Date` object accordingly. For example, if you
698 * specify 15 for `monthValue`, the year is incremented by 1 (year + 1), and 3 is used for the month.
700 * theBigDay = new Date();
701 * theBigDay.setUTCFullYear(1997);
703 * @param {Number} yearValue An integer specifying the numeric value of the year, for example, 1995.
704 * @param {Number} monthValue An integer between 0 and 11 representing the months January through
706 * @param {Number} dayValue An integer between 1 and 31 representing the day of the month. If you
707 * specify the `dayValue` parameter, you must also specify the `monthValue`.
708 * @return {Number} New date represented as milliseconds.
711 <span id='Date-method-setUTCHours'>/**
712 </span> * @method setUTCHours
713 * Sets the hour (0-23) for a specified date according to universal time.
715 * If you do not specify the `minutesValue`, `secondsValue`, and `msValue` parameters, the values
716 * returned from the `getUTCMinutes`, `getUTCSeconds`, and `getUTCMilliseconds` methods are used.
718 * If a parameter you specify is outside of the expected range, `setUTCHours` attempts to update the
719 * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
720 * the minutes will be incremented by 1 (min + 1), and 40 will be used for seconds.
722 * theBigDay = new Date();
723 * theBigDay.setUTCHours(8);
725 * @param {Number} hoursValue An integer between 0 and 23, representing the hour.
726 * @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
727 * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the
728 * `secondsValue` parameter, you must also specify the `minutesValue`.
729 * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the
730 * `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
731 * @return {Number} New date represented as milliseconds.
734 <span id='Date-method-setUTCMilliseconds'>/**
735 </span> * @method setUTCMilliseconds
736 * Sets the milliseconds (0-999) for a specified date according to universal time.
738 * If a parameter you specify is outside of the expected range, `setUTCMilliseconds` attempts to
739 * update the date information in the `Date` object accordingly. For example, if you use 1100 for
740 * `millisecondsValue`, the seconds stored in the Date object will be incremented by 1, and 100 will
741 * be used for milliseconds.
743 * theBigDay = new Date();
744 * theBigDay.setUTCMilliseconds(500);
746 * @param {Number} millisecondsValue A number between 0 and 999, representing the milliseconds.
747 * @return {Number} New date represented as milliseconds.
750 <span id='Date-method-setUTCMinutes'>/**
751 </span> * @method setUTCMinutes
752 * Sets the minutes (0-59) for a specified date according to universal time.
754 * If you do not specify the `secondsValue` and `msValue` parameters, the values returned from
755 * `getUTCSeconds` and `getUTCMilliseconds` methods are used.
757 * If a parameter you specify is outside of the expected range, `setUTCMinutes` attempts to update the
758 * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
759 * the minutes (`minutesValue`) will be incremented by 1 (`minutesValue` + 1), and 40 will be used for
762 * theBigDay = new Date();
763 * theBigDay.setUTCMinutes(43);
765 * @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
766 * @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the `secondsValue` parameter, you must also specify the `minutesValue`.
767 * @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
768 * @return {Number} New date represented as milliseconds.
771 <span id='Date-method-setUTCMonth'>/**
772 </span> * @method setUTCMonth
773 * Sets the month (0-11) for a specified date according to universal time.
775 * If you do not specify the `dayValue` parameter, the value returned from the `getUTCDate` method is
778 * If a parameter you specify is outside of the expected range, `setUTCMonth` attempts to update the
779 * date information in the `Date` object accordingly. For example, if you use 15 for `monthValue`, the
780 * year will be incremented by 1 (year + 1), and 3 will be used for month.
782 * theBigDay = new Date();
783 * theBigDay.setUTCMonth(11);
785 * @param {Number} monthValue An integer between 0 and 11, representing the months January through
787 * @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
788 * @return {Number} New date represented as milliseconds.
791 <span id='Date-method-setUTCSeconds'>/**
792 </span> * @method setUTCSeconds
793 * Sets the seconds (0-59) for a specified date according to universal time.
795 * If you do not specify the `msValue` parameter, the value returned from the `getUTCMilliseconds`
798 * If a parameter you specify is outside of the expected range, `setUTCSeconds` attempts to update the
799 * date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
800 * the minutes stored in the `Date` object will be incremented by 1, and 40 will be used for seconds.
802 * theBigDay = new Date();
803 * theBigDay.setUTCSeconds(20);
805 * @param {Number} secondsValue An integer between 0 and 59.
806 * @param {Number} msValue A number between 0 and 999, representing the milliseconds.
807 * @return {Number} New date represented as milliseconds.
810 <span id='Date-method-toDateString'>/**
811 </span> * @method toDateString
812 * Returns the "date" portion of the Date as a human-readable string in American English.
814 * {@link Date} instances refer to a specific point in time. Calling `toString` will return the
815 * date formatted in a human readable form in American English. In SpiderMonkey, this consists of the
816 * date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and time
817 * zone). Sometimes it is desirable to obtain a string of the date portion; such a thing can be
818 * accomplished with the `toDateString` method.
820 * The `toDateString` method is especially useful because compliant engines implementing ECMA-262 may
821 * differ in the string obtained from `toString` for `Date` objects, as the format is implementation-
822 * dependent and simple string slicing approaches may not produce consistent results across multiple
825 * var d = new Date(1993, 6, 28, 14, 39, 7);
826 * println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
827 * println(d.toDateString()); // prints Wed Jul 28 1993
829 * @return {String} Human-readable string, in local time.
832 <span id='Date-method-toLocaleDateString'>/**
833 </span> * @method toLocaleDateString
834 * Returns the "date" portion of the Date as a string, using the current locale's
837 * The `toLocaleDateString` method relies on the underlying operating system in formatting dates. It
838 * converts the date to a string using the formatting convention of the operating system where the
839 * script is running. For example, in the United States, the month appears before the date (04/15/98),
840 * whereas in Germany the date appears before the month (15.04.98). If the operating system is not
841 * year-2000 compliant and does not use the full year for years before 1900 or over 2000,
842 * `toLocaleDateString` returns a string that is not year-2000 compliant. `toLocaleDateString` behaves
843 * similarly to `toString` when converting a year that the operating system does not properly format.
845 * Methods such as `getDate`, `getMonth`, and `getFullYear` give more portable results than
846 * `toLocaleDateString`. Use `toLocaleDateString` when the intent is to display to the user a string
847 * formatted using the regional format chosen by the user. Be aware that this method, due to its
848 * nature, behaves differently depending on the operating system and on the user's settings.
850 * In the following example, `today` is a `Date` object:
852 * today = new Date(95,11,18,17,28,35) //months are represented by 0 to 11
853 * today.toLocaleDateString()
855 * In this example, `toLocaleDateString` returns a string value that is similar to the following form.
856 * The exact format depends on the platform, locale and user's settings.
860 * You shouldn't use this method in contexts where you rely on a particular format or locale.
862 * "Last visit: " + someDate.toLocaleDateString(); // Good example
863 * "Last visit was at " + someDate.toLocaleDateString(); // Bad example
865 * @return {String} Human-readable string that may be formatted differently depending
869 <span id='Date-method-toLocaleString'>/**
870 </span> * @method toLocaleString
871 * Converts a date to a string, using the current locale's conventions. Overrides
872 * the `Object.toLocaleString` method.
874 * The `toLocaleString` method relies on the underlying operating system in formatting dates. It
875 * converts the date to a string using the formatting convention of the operating system where the
876 * script is running. For example, in the United States, the month appears before the date (04/15/98),
877 * whereas in Germany the date appears before the month (15.04.98). If the operating system is not
878 * year-2000 compliant and does not use the full year for years before 1900 or over 2000,
879 * `toLocaleString` returns a string that is not year-2000 compliant. `toLocaleString` behaves
880 * similarly to `toString` when converting a year that the operating system does not properly format.
882 * Methods such as `getDate`, `getMonth`, `getFullYear`, `getHours`, `getMinutes`, and `getSeconds`
883 * give more portable results than `toLocaleString`. Use `toLocaleString` when the intent is to
884 * display to the user a string formatted using the regional format chosen by the user. Be aware that
885 * this method, due to its nature, behaves differently depending on the operating system and on the
888 * In the following example, `today` is a `Date` object:
890 * today = new Date(95,11,18,17,28,35); //months are represented by 0 to 11
891 * today.toLocaleString();
893 * In this example, `toLocaleString` returns a string value that is similar to the following form. The
894 * exact format depends on the platform, locale and user's settings.
898 * You shouldn't use this method in contexts where you rely on a particular format or locale.
900 * "Last visit: " + someDate.toLocaleString(); // Good example
901 * "Last visit was at " + someDate.toLocaleString(); // Bad example
903 * @return {String} Human-readable string that may be formatted differently depending
907 <span id='Date-method-toLocaleTimeString'>/**
908 </span> * @method toLocaleTimeString
909 * Returns the "time" portion of the Date as a string, using the current locale's
912 * The `toLocaleTimeString` method relies on the underlying operating system in formatting dates. It
913 * converts the date to a string using the formatting convention of the operating system where the
914 * script is running. For example, in the United States, the month appears before the date (04/15/98),
915 * whereas in Germany the date appears before the month (15.04.98).
917 * Methods such as `getHours`, `getMinutes`, and `getSeconds` give more consistent results than
918 * `toLocaleTimeString`. Use `toLocaleTimeString` when the intent is to display to the user a string
919 * formatted using the regional format chosen by the user. Be aware that this method, due to its
920 * nature, behaves differently depending on the operating system and on the user's settings.
922 * In the following example, `today` is a `Date` object:
924 * today = new Date(95,11,18,17,28,35) //months are represented by 0 to 11
925 * today.toLocaleTimeString()
927 * In this example, `toLocaleTimeString` returns a string value that is similar to the following form.
928 * The exact format depends on the platform.
932 * You shouldn't use this method in contexts where you rely on a particular format or locale.
934 * "Last visit: " + someDate.toLocaleTimeString(); // Good example
935 * "Last visit was at " + someDate.toLocaleTimeString(); // Bad example
937 * @return {String} Human-readable string that may be formatted differently depending
941 <span id='Date-method-toString'>/**
942 </span> * @method toString
943 * Returns a string representing the specified Date object. Overrides the
944 * `Object.prototype.toString` method.
946 * The `Date` object overrides the toString method of the Object object; it does not inherit
947 * `Object.toString`. For `Date` objects, the `toString` method returns a string representation of the
950 * `toString` always returns a string representation of the date in American English.
952 * JavaScript calls the `toString` method automatically when a date is to be represented as a text
953 * value or when a date is referred to in a string concatenation.
955 * The following assigns the `toString` value of a `Date` object to `myVar`:
958 * myVar=x.toString(); //assigns a value to myVar similar to:
959 * //Mon Sep 28 1998 14:36:22 GMT-0700 (Pacific Daylight Time)
961 * @return {String} Human-readable string of the date in local time.
964 <span id='Date-method-toTimeString'>/**
965 </span> * @method toTimeString
966 * Returns the "time" portion of the Date as a human-readable string.
968 * {@link Date} instances refer to a specific point in time. Calling `toString` will return the
969 * date formatted in a human readable form in American English. In SpiderMonkey, this consists of the
970 * date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and
971 * time zone). Sometimes it is desirable to obtain a string of the time portion; such a thing can be
972 * accomplished with the `toTimeString` method.
974 * The `toTimeString` method is especially useful because compliant engines implementing ECMA-262 may
975 * differ in the string obtained from `toString` for `Date` objects, as the format is implementation-
976 * dependent; simple string slicing approaches may not produce consistent results across multiple
979 * var d = new Date(1993, 6, 28, 14, 39, 7);
980 * println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
981 * println(d.toTimeString()); // prints 14:39:07 GMT-0600 (PDT)
983 * @return {String} Human-readable string of the date in local time.
986 <span id='Date-method-toUTCString'>/**
987 </span> * @method toUTCString
988 * Converts a date to a string, using the universal time convention.
990 * The value returned by `toUTCString` is a readable string in American English in the UTC time zone.
991 * The format of the return value may vary according to the platform.
993 * var today = new Date();
994 * var UTCstring = today.toUTCString();
995 * // Mon, 03 Jul 2006 21:44:38 GMT
997 * @return {String} String of the date in UTC.
1000 <span id='Date-method-valueOf'>/**
1001 </span> * @method valueOf
1002 * Returns the primitive value of a Date object. Overrides the
1003 * Object.prototype.valueOf method.
1005 * The `valueOf` method returns the primitive value of a `Date` object as a number data type, the
1006 * number of milliseconds since midnight 01 January, 1970 UTC.
1008 * This method is functionally equivalent to the `getTime` method.
1010 * This method is usually called internally by JavaScript and not explicitly in code.
1012 * x = new Date(56, 6, 17);
1013 * myVar = x.valueOf(); //assigns -424713600000 to myVar
1015 * @return {Number} Date represented as milliseconds.