764 lines
No EOL
36 KiB
HTML
764 lines
No EOL
36 KiB
HTML
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>Date</title>
|
|
<link rel="stylesheet" type="text/css" href="../resources/reset.css"/>
|
|
<link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/>
|
|
<link rel="stylesheet" type="text/css" href="../resources/print.css" media="print">
|
|
<!-- GC -->
|
|
</head>
|
|
<body>
|
|
<div class="body-wrap">
|
|
<div class="top-tools">
|
|
<img src="../resources/print.gif" width="16" height="16" align="absmiddle"> <a href="Date.html" target="_blank">Print Friendly</a><br/>
|
|
|
|
</div>
|
|
<h1>Class Date</h1>
|
|
<table cellspacing="0">
|
|
<tr><td class="label">Package:</td><td>Global</td></tr>
|
|
<tr><td class="label">Class:</td><td>Date</td></tr>
|
|
<tr><td class="label">Extends:</td><td>Object</td></tr>
|
|
<tr><td class="label">Defined In:</td><td><a href="Date.jss.html">Date.js</a></td></tr>
|
|
</table>
|
|
<div class="description">
|
|
The date parsing and format syntax is a subset of
|
|
<a href="http://www.php.net/date">PHP's date() function</a>, and the formats that are
|
|
supported will provide results equivalent to their PHP versions.
|
|
Following is the list of all currently supported formats:
|
|
<pre>
|
|
Sample date:
|
|
'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'
|
|
|
|
Format Output Description
|
|
------ ---------- --------------------------------------------------------------
|
|
d 10 Day of the month, 2 digits with leading zeros
|
|
D Wed A textual representation of a day, three letters
|
|
j 10 Day of the month without leading zeros
|
|
l Wednesday A full textual representation of the day of the week
|
|
S th English ordinal day of month suffix, 2 chars (use with j)
|
|
w 3 Numeric representation of the day of the week
|
|
z 9 The julian date, or day of the year (0-365)
|
|
W 01 ISO-8601 2-digit week number of year, weeks starting on Monday (00-52)
|
|
F January A full textual representation of the month
|
|
m 01 Numeric representation of a month, with leading zeros
|
|
M Jan Month name abbreviation, three letters
|
|
n 1 Numeric representation of a month, without leading zeros
|
|
t 31 Number of days in the given month
|
|
L 0 Whether it's a leap year (1 if it is a leap year, else 0)
|
|
Y 2007 A full numeric representation of a year, 4 digits
|
|
y 07 A two digit representation of a year
|
|
a pm Lowercase Ante meridiem and Post meridiem
|
|
A PM Uppercase Ante meridiem and Post meridiem
|
|
g 3 12-hour format of an hour without leading zeros
|
|
G 15 24-hour format of an hour without leading zeros
|
|
h 03 12-hour format of an hour with leading zeros
|
|
H 15 24-hour format of an hour with leading zeros
|
|
i 05 Minutes with leading zeros
|
|
s 01 Seconds, with leading zeros
|
|
O -0600 Difference to Greenwich time (GMT) in hours
|
|
T CST Timezone setting of the machine running the code
|
|
Z -21600 Timezone offset in seconds (negative if west of UTC, positive if east)
|
|
</pre>
|
|
Example usage (note that you must escape format specifiers with '\\' to render them as character literals):
|
|
<pre class="highlighted"><code>var dt = <b>new</b> Date('1/10/2007 03:05:01 PM GMT-0600');
|
|
document.write(dt.format('Y-m-d')); <i>//2007-01-10</i>
|
|
document.write(dt.format('F j, Y, g:i a')); <i>//January 10, 2007, 3:05 pm</i>
|
|
document.write(dt.format('l, \\t\\he dS of F Y h:i:s A')); //Wednesday, the 10th of January 2007 03:05:01 PM</code></pre>
|
|
Here are some standard date/time patterns that you might find helpful. They
|
|
are not part of the source of Date.js, but to use them you can simply copy this
|
|
block of code into any script that is included after Date.js and they will also become
|
|
globally available on the Date object. Feel free to add or remove patterns as needed in your code.
|
|
<pre><code>
|
|
Date.patterns = {
|
|
ISO8601Long:"Y-m-d H:i:s",
|
|
ISO8601Short:"Y-m-d",
|
|
ShortDate: "n/j/Y",
|
|
LongDate: "l, F d, Y",
|
|
FullDateTime: "l, F d, Y g:i:s A",
|
|
MonthDay: "F d",
|
|
ShortTime: "g:i A",
|
|
LongTime: "g:i:s A",
|
|
SortableDateTime: "Y-m-d\\TH:i:s",
|
|
UniversalSortableDateTime: "Y-m-d H:i:sO",
|
|
YearMonth: "F, Y"
|
|
};
|
|
</code></pre>
|
|
Example usage:
|
|
<pre><code>
|
|
var dt = new Date();
|
|
document.write(dt.format(Date.patterns.ShortDate));
|
|
</code></pre> </div>
|
|
<br />
|
|
<a href="#properties">Properties</a>
|
|
- <a href="#methods">Methods</a>
|
|
- <a href="#events">Events</a>
|
|
<hr />
|
|
<a name="properties"></a>
|
|
<h2>Public Properties</h2>
|
|
<table cellspacing="0" class="member-table">
|
|
<tr>
|
|
<th class="sig-header" colspan="2">Property</th>
|
|
<th class="msource-header">Defined By</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.DAY">Date.DAY</a> : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc"><static> Date interval constant</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.HOUR">Date.HOUR</a> : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc"><static> Date interval constant</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.MILLI">Date.MILLI</a> : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc"><static> Date interval constant</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.MINUTE">Date.MINUTE</a> : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc"><static> Date interval constant</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.MONTH">Date.MONTH</a> : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc"><static> Date interval constant</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.SECOND">Date.SECOND</a> : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc"><static> Date interval constant</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.YEAR">Date.YEAR</a> : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc"><static> Date interval constant</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.dayNames">Date.dayNames</a> : Array</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc"><static> An array of textual day names.
|
|
Override these values for international dates, for example...
|
|
Date.dayN...</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.monthNames">Date.monthNames</a> : Array</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc"><static> An array of textual month names.
|
|
Override these values for international dates, for example...
|
|
Date.mo...</td>
|
|
</tr>
|
|
</table>
|
|
<a name="methods"></a>
|
|
<h2>Public Methods</h2>
|
|
<table cellspacing="0" class="member-table">
|
|
<tr>
|
|
<th class="sig-header" colspan="2">Method</th>
|
|
<th class="msource-header">Defined By</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#Date.parseDate">Date.parseDate</a>(<code>String input</code>, <code>String format</code>) : Date</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc"><static> Parses the passed string using the specified format. Example Usage:
|
|
|
|
var date = Date.parseDate('2006...</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#add">add</a>(<code>String interval</code>, <code>Number value</code>) : Date</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Provides a convenient method of performing basic date arithmetic. This method
|
|
does not modify the Date instance bein...</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#clearTime">clearTime</a>(<code>Boolean clone</code>) : Date</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Clears any time information from this date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#clone">clone</a>() : Date</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Creates and returns a new Date instance with the exact same date value as the called instance.
|
|
Dates are copied and p...</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#format">format</a>(<code>String format</code>) : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Formats a date given the supplied format string</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getDayOfYear">getDayOfYear</a>() : Number</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Get the numeric day number of the year, adjusted for leap year.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getDaysInMonth">getDaysInMonth</a>() : Number</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Get the number of days in the current month, adjusted for leap year.</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getElapsed">getElapsed</a>(<span class="optional" title="Optional">[<code>Date date</code>]</span>) : Number</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Returns the number of milliseconds between this date and date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getFirstDateOfMonth">getFirstDateOfMonth</a>() : Date</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Get a Date of the first day of this date's month</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getFirstDayOfMonth">getFirstDayOfMonth</a>() : Number</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Get the first day of the current month, adjusted for leap year. The returned value
|
|
is the numeric day index within t...</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getGMTOffset">getGMTOffset</a>() : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Get the offset from GMT of the current date (equivalent to the format specifier 'O').</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getLastDateOfMonth">getLastDateOfMonth</a>() : Date</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Get a Date of the late day of this date's month</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getLastDayOfMonth">getLastDayOfMonth</a>() : Number</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Get the last day of the current month, adjusted for leap year. The returned value
|
|
is the numeric day index within th...</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getSuffix">getSuffix</a>() : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getTimezone">getTimezone</a>() : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Get the timezone abbreviation of the current date (equivalent to the format specifier 'T').</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#getWeekOfYear">getWeekOfYear</a>() : String</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr class="alt">
|
|
<td class="mdesc">Get the string representation of the numeric week number of the year
|
|
(equivalent to the format specifier 'W').</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="micon" rowspan="2"> </td>
|
|
<td class="sig"><a class="mlink" href="#isLeapYear">isLeapYear</a>() : Boolean</td>
|
|
<td class="msource" rowspan="2">Date</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="mdesc">Whether or not the current date is in a leap year.</td>
|
|
</tr>
|
|
</table>
|
|
<a name="events"></a>
|
|
<h2>Public Events</h2>
|
|
<div class="no-members">This class has no public events.</div> <h2 class="mdetail-head">Property Details</h2>
|
|
<div class="detail-wrap">
|
|
<a name="Date.DAY"></a>
|
|
<div class="mdetail">
|
|
<h3>Date.DAY</i></h3>
|
|
<code>public String Date.DAY</code>
|
|
<div class="mdetail-desc">
|
|
<static> Date interval constant </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.HOUR"></a>
|
|
<div class="mdetail alt">
|
|
<h3>Date.HOUR</i></h3>
|
|
<code>public String Date.HOUR</code>
|
|
<div class="mdetail-desc">
|
|
<static> Date interval constant </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.MILLI"></a>
|
|
<div class="mdetail">
|
|
<h3>Date.MILLI</i></h3>
|
|
<code>public String Date.MILLI</code>
|
|
<div class="mdetail-desc">
|
|
<static> Date interval constant </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.MINUTE"></a>
|
|
<div class="mdetail alt">
|
|
<h3>Date.MINUTE</i></h3>
|
|
<code>public String Date.MINUTE</code>
|
|
<div class="mdetail-desc">
|
|
<static> Date interval constant </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.MONTH"></a>
|
|
<div class="mdetail">
|
|
<h3>Date.MONTH</i></h3>
|
|
<code>public String Date.MONTH</code>
|
|
<div class="mdetail-desc">
|
|
<static> Date interval constant </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.SECOND"></a>
|
|
<div class="mdetail alt">
|
|
<h3>Date.SECOND</i></h3>
|
|
<code>public String Date.SECOND</code>
|
|
<div class="mdetail-desc">
|
|
<static> Date interval constant </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.YEAR"></a>
|
|
<div class="mdetail">
|
|
<h3>Date.YEAR</i></h3>
|
|
<code>public String Date.YEAR</code>
|
|
<div class="mdetail-desc">
|
|
<static> Date interval constant </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.dayNames"></a>
|
|
<div class="mdetail alt">
|
|
<h3>Date.dayNames</i></h3>
|
|
<code>public Array Date.dayNames</code>
|
|
<div class="mdetail-desc">
|
|
<static> An array of textual day names.
|
|
Override these values for international dates, for example...
|
|
Date.dayNames = ['SundayInYourLang', 'MondayInYourLang', ...]; </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
<a name="Date.monthNames"></a>
|
|
<div class="mdetail">
|
|
<h3>Date.monthNames</i></h3>
|
|
<code>public Array Date.monthNames</code>
|
|
<div class="mdetail-desc">
|
|
<static> An array of textual month names.
|
|
Override these values for international dates, for example...
|
|
Date.monthNames = ['JanInYourLang', 'FebInYourLang', ...]; </div>
|
|
<div class="mdetail-def">This property is defined by Date.</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h2 class="mdetail-head">Method Details</h2>
|
|
<div class="detail-wrap">
|
|
<a name="Date.parseDate"></a>
|
|
<div class="mdetail">
|
|
<h3>Date.parseDate</i></h3>
|
|
<code>public function Date.parseDate(<code>String input</code>, <code>String format</code>)</code>
|
|
<div class="mdetail-desc">
|
|
<static> Parses the passed string using the specified format. Example Usage:
|
|
<pre><code>
|
|
var date = Date.parseDate('2006-12-25', 'Y-m-d');
|
|
</code></pre>
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<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>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Date</code><div class="sub-desc">The parsed date</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="add"></a>
|
|
<div class="mdetail alt">
|
|
<h3>add</i></h3>
|
|
<code>public function add(<code>String interval</code>, <code>Number value</code>)</code>
|
|
<div class="mdetail-desc">
|
|
Provides a convenient method of performing basic date arithmetic. This method
|
|
does not modify the Date instance being called - it creates and returns
|
|
a new Date instance containing the resulting date value.
|
|
Examples:
|
|
<pre><code>
|
|
//Basic usage:
|
|
var dt = new Date('10/29/2006').add(Date.DAY, 5);
|
|
document.write(dt); //returns 'Fri Oct 06 2006 00:00:00'
|
|
|
|
//Negative values will subtract correctly:
|
|
var dt2 = new Date('10/1/2006').add(Date.DAY, -5);
|
|
document.write(dt2); //returns 'Tue Sep 26 2006 00:00:00'
|
|
|
|
//You can even chain several calls together in one line!
|
|
var dt3 = new Date('10/1/2006').add(Date.DAY, 5).add(Date.HOUR, 8).add(Date.MINUTE, -30);
|
|
document.write(dt3); //returns 'Fri Oct 06 2006 07:30:00'
|
|
</code></pre>
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<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>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Date</code><div class="sub-desc">The new Date instance</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="clearTime"></a>
|
|
<div class="mdetail">
|
|
<h3>clearTime</i></h3>
|
|
<code>public function clearTime(<code>Boolean clone</code>)</code>
|
|
<div class="mdetail-desc">
|
|
Clears any time information from this date
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li><code>clone</code> : Boolean<div class="sub-desc">true to create a clone of this date, clear the time and return it</div></li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Date</code><div class="sub-desc">this or the clone</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="clone"></a>
|
|
<div class="mdetail alt">
|
|
<h3>clone</i></h3>
|
|
<code>public function clone()</code>
|
|
<div class="mdetail-desc">
|
|
Creates and returns a new Date instance with the exact same date value as the called instance.
|
|
Dates are copied and passed by reference, so if a copied date variable is modified later, the original
|
|
variable will also be changed. When the intention is to create a new variable that will not
|
|
modify the original instance, you should create a clone.
|
|
Example of correctly cloning a date:
|
|
<pre><code>
|
|
//wrong way:
|
|
var orig = new Date('10/1/2006');
|
|
var copy = orig;
|
|
copy.setDate(5);
|
|
document.write(orig); //returns 'Thu Oct 05 2006'!
|
|
|
|
//correct way:
|
|
var orig = new Date('10/1/2006');
|
|
var copy = orig.clone();
|
|
copy.setDate(5);
|
|
document.write(orig); //returns 'Thu Oct 01 2006'
|
|
</code></pre>
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Date</code><div class="sub-desc">The new Date instance</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="format"></a>
|
|
<div class="mdetail">
|
|
<h3>format</i></h3>
|
|
<code>public function format(<code>String format</code>)</code>
|
|
<div class="mdetail-desc">
|
|
Formats a date given the supplied format string
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li><code>format</code> : String<div class="sub-desc">The format string</div></li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>String</code><div class="sub-desc">The formatted date</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getDayOfYear"></a>
|
|
<div class="mdetail alt">
|
|
<h3>getDayOfYear</i></h3>
|
|
<code>public function getDayOfYear()</code>
|
|
<div class="mdetail-desc">
|
|
Get the numeric day number of the year, adjusted for leap year.
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Number</code><div class="sub-desc">0 through 365 (366 in leap years)</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getDaysInMonth"></a>
|
|
<div class="mdetail">
|
|
<h3>getDaysInMonth</i></h3>
|
|
<code>public function getDaysInMonth()</code>
|
|
<div class="mdetail-desc">
|
|
Get the number of days in the current month, adjusted for leap year.
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Number</code><div class="sub-desc">The number of days in the month</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getElapsed"></a>
|
|
<div class="mdetail alt">
|
|
<h3>getElapsed</i></h3>
|
|
<code>public function getElapsed(<span class="optional" title="Optional">[<code>Date date</code>]</span>)</code>
|
|
<div class="mdetail-desc">
|
|
Returns the number of milliseconds between this date and date
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li><code>date</code> : Date<div class="sub-desc">(optional) Defaults to now</div></li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Number</code><div class="sub-desc">The diff in milliseconds</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getFirstDateOfMonth"></a>
|
|
<div class="mdetail">
|
|
<h3>getFirstDateOfMonth</i></h3>
|
|
<code>public function getFirstDateOfMonth()</code>
|
|
<div class="mdetail-desc">
|
|
Get a Date of the first day of this date's month
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Date</code></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getFirstDayOfMonth"></a>
|
|
<div class="mdetail alt">
|
|
<h3>getFirstDayOfMonth</i></h3>
|
|
<code>public function getFirstDayOfMonth()</code>
|
|
<div class="mdetail-desc">
|
|
Get the first day of the current month, adjusted for leap year. The returned value
|
|
is the numeric day index within the week (0-6) which can be used in conjunction with
|
|
the <a href="#monthNames">monthNames</a> array to retrieve the textual day name.
|
|
Example:
|
|
<pre><code>
|
|
var dt = new Date('1/10/2007');
|
|
document.write(Date.dayNames[dt.getFirstDayOfMonth()]); //output: 'Monday'
|
|
</code></pre>
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Number</code><div class="sub-desc">The day number (0-6)</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getGMTOffset"></a>
|
|
<div class="mdetail">
|
|
<h3>getGMTOffset</i></h3>
|
|
<code>public function getGMTOffset()</code>
|
|
<div class="mdetail-desc">
|
|
Get the offset from GMT of the current date (equivalent to the format specifier 'O').
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>String</code><div class="sub-desc">The 4-character offset string prefixed with + or - (e.g. '-0600')</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getLastDateOfMonth"></a>
|
|
<div class="mdetail alt">
|
|
<h3>getLastDateOfMonth</i></h3>
|
|
<code>public function getLastDateOfMonth()</code>
|
|
<div class="mdetail-desc">
|
|
Get a Date of the late day of this date's month
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Date</code></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getLastDayOfMonth"></a>
|
|
<div class="mdetail">
|
|
<h3>getLastDayOfMonth</i></h3>
|
|
<code>public function getLastDayOfMonth()</code>
|
|
<div class="mdetail-desc">
|
|
Get the last day of the current month, adjusted for leap year. The returned value
|
|
is the numeric day index within the week (0-6) which can be used in conjunction with
|
|
the <a href="#monthNames">monthNames</a> array to retrieve the textual day name.
|
|
Example:
|
|
<pre><code>
|
|
var dt = new Date('1/10/2007');
|
|
document.write(Date.dayNames[dt.getLastDayOfMonth()]); //output: 'Wednesday'
|
|
</code></pre>
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Number</code><div class="sub-desc">The day number (0-6)</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getSuffix"></a>
|
|
<div class="mdetail alt">
|
|
<h3>getSuffix</i></h3>
|
|
<code>public function getSuffix()</code>
|
|
<div class="mdetail-desc">
|
|
Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>String</code><div class="sub-desc">'st, 'nd', 'rd' or 'th'</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getTimezone"></a>
|
|
<div class="mdetail">
|
|
<h3>getTimezone</i></h3>
|
|
<code>public function getTimezone()</code>
|
|
<div class="mdetail-desc">
|
|
Get the timezone abbreviation of the current date (equivalent to the format specifier 'T').
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>String</code><div class="sub-desc">The abbreviated timezone name (e.g. 'CST')</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="getWeekOfYear"></a>
|
|
<div class="mdetail alt">
|
|
<h3>getWeekOfYear</i></h3>
|
|
<code>public function getWeekOfYear()</code>
|
|
<div class="mdetail-desc">
|
|
Get the string representation of the numeric week number of the year
|
|
(equivalent to the format specifier 'W').
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>String</code><div class="sub-desc">'00' through '52'</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
<a name="isLeapYear"></a>
|
|
<div class="mdetail">
|
|
<h3>isLeapYear</i></h3>
|
|
<code>public function isLeapYear()</code>
|
|
<div class="mdetail-desc">
|
|
Whether or not the current date is in a leap year.
|
|
<div class="mdetail-params">
|
|
<strong>Parameters:</strong>
|
|
<ul><li>None.</li> </ul>
|
|
<strong>Returns:</strong>
|
|
<ul>
|
|
<li><code>Boolean</code><div class="sub-desc">True if the current date is in a leap year, else false</div></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="mdetail-def">This method is defined by Date.</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
<hr>
|
|
<div style="font-size:10px;text-align:center;color:gray;">Ext - Copyright © 2006-2007 Ext JS, LLC<br />All rights reserved.</div>
|
|
|
|
</body>
|
|
</html> |