date.html.svn-base
来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· SVN-BASE 代码 · 共 747 行 · 第 1/3 页
SVN-BASE
747 行
<div class="body-wrap"> <div class="top-tools"> <a class="inner-link" href="#Date-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a> <a class="inner-link" href="#Date-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a> <a class="inner-link" href="#Date-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a> <a class="bookmark" href="../docs/?class=Date"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a> </div> <h1>Class Date</h1> <table cellspacing="0"> <tr><td class="label">Package:</td><td class="hd-info">Global</td></tr> <tr><td class="label">Defined In:</td><td class="hd-info">Date.js</td></tr> <tr><td class="label">Class:</td><td class="hd-info">Date</td></tr> <tr><td class="label">Extends:</td><td class="hd-info">Object</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 aresupported will provide results equivalent to their PHP versions.The following is a list of all currently supported formats:<pre>Format Description Example returned values------ ----------------------------------------------------------------------- ----------------------- d Day of the month, 2 digits with leading zeros 01 to 31 D A short textual representation of the day of the week Mon to Sun j Day of the month without leading zeros 1 to 31 l A full textual representation of the day of the week Sunday to Saturday N ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday) S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j w Numeric representation of the day of the week 0 (for Sunday) to 6 (for Saturday) z The day of the year (starting from 0) 0 to 364 (365 in leap years) W ISO-8601 week number of year, weeks starting on Monday 01 to 53 F A full textual representation of a month, such as January or March January to December m Numeric representation of a month, with leading zeros 01 to 12 M A short textual representation of a month Jan to Dec n Numeric representation of a month, without leading zeros 1 to 12 t Number of days in the given month 28 to 31 L Whether it's a leap year 1 if it is a leap year, 0 otherwise. o ISO-8601 year number (identical to (Y), but if the ISO week number (W) Examples: 1998 or 2004 belongs to the previous or next year, that year is used instead) Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003 y A two digit representation of a year Examples: 99 or 03 a Lowercase Ante meridiem and Post meridiem am or pm A Uppercase Ante meridiem and Post meridiem AM or PM g 12-hour format of an hour without leading zeros 1 to 12 G 24-hour format of an hour without leading zeros 0 to 23 h 12-hour format of an hour with leading zeros 01 to 12 H 24-hour format of an hour with leading zeros 00 to 23 i Minutes, with leading zeros 00 to 59 s Seconds, with leading zeros 00 to 59 u Milliseconds, with leading zeros 001 to 999 O Difference to Greenwich time (GMT) in hours and minutes Example: +1030 P Difference to Greenwich time (GMT) with colon between hours and minutes Example: -08:00 T Timezone abbreviation of the machine running the code Examples: EST, MDT, PDT ... Z Timezone offset in seconds (negative if west of UTC, positive if east) -43200 to 50400 c ISO 8601 date 2007-04-17T15:19:21+08:00 or 2007-04-17T15:19:21Z U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 1193432466 or -2138434463</pre>Example usage (note that you must escape format specifiers with '\\' to render them as character literals):<pre><code><i>// Sample date:</i><i>// <em>'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'</em></i><b>var</b> dt = <b>new</b> Date(<em>'1/10/2007 03:05:01 PM GMT-0600'</em>);document.write(dt.format(<em>'Y-m-d'</em>)); <i>// 2007-01-10</i>document.write(dt.format(<em>'F j, Y, g:i a'</em>)); <i>// January 10, 2007, 3:05 pm</i>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>Here are some standard date/time patterns that you might find helpful. Theyare not part of the source of Date.js, but to use them you can simply copy thisblock of code into any script that is included after Date.js and they will also becomeglobally available on the Date object. Feel free to add or remove patterns as needed in your code.<pre><code>Date.patterns = { ISO8601Long:<em>"Y-m-d H:i:s"</em>, ISO8601Short:<em>"Y-m-d"</em>, ShortDate: <em>"n/j/Y"</em>, LongDate: <em>"l, F d, Y"</em>, FullDateTime: <em>"l, F d, Y g:i:s A"</em>, MonthDay: <em>"F d"</em>, ShortTime: <em>"g:i A"</em>, LongTime: <em>"g:i:s A"</em>, SortableDateTime: <em>"Y-m-d\\TH:i:s"</em>, UniversalSortableDateTime: <em>"Y-m-d H:i:sO"</em>, YearMonth: <em>"F, Y"</em>};</code></pre>Example usage:<pre><code>var dt = <b>new</b> Date();document.write(dt.format(Date.patterns.ShortDate));</code></pre> </div> <div class="hr"></div> <a id="Date-props"></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 class="property-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.DAY"></a>
<b>Date.DAY</b> : String <div class="mdesc">
<static> Date interval constant </div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.HOUR"></a>
<b>Date.HOUR</b> : String <div class="mdesc">
<static> Date interval constant </div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.MILLI"></a>
<b>Date.MILLI</b> : String <div class="mdesc">
<static> Date interval constant </div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.MINUTE"></a>
<b>Date.MINUTE</b> : String <div class="mdesc">
<static> Date interval constant </div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.MONTH"></a>
<b>Date.MONTH</b> : String <div class="mdesc">
<static> Date interval constant </div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row alt">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.SECOND"></a>
<b>Date.SECOND</b> : String <div class="mdesc">
<static> Date interval constant </div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.YEAR"></a>
<b>Date.YEAR</b> : String <div class="mdesc">
<static> Date interval constant </div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.dayNames"></a>
<b>Date.dayNames</b> : Array <div class="mdesc">
<div class="short"><static> An array of textual day names.Override these values for international dates.Example:Date.dayNames =...</div>
<div class="long">
<static> An array of textual day names.Override these values for international dates.Example:<pre><code>Date.dayNames = [ <em>'SundayInYourLang'</em>, <em>'MondayInYourLang'</em>, ...];</code></pre> </div>
</div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.formatCodes"></a>
<b>Date.formatCodes</b> : Object <div class="mdesc">
<div class="short"><static> The base format-code to formatting-function hashmap used by the format method.Formatting functions ar...</div>
<div class="long">
<static> The base format-code to formatting-function hashmap used by the <a ext:cls="Date" ext:member="format" href="output/Date.html#format">format</a> method.Formatting functions are strings (or functions which return strings) whichwill return the appropriate value when evaluated in the context of the Date objectfrom which the <a ext:cls="Date" ext:member="format" href="output/Date.html#format">format</a> method is called.Add to / override these mappings for custom date formatting.Note: Date.format() treats characters as literals if an appropriate mapping cannot be found.Example:<pre><code>Date.formatCodes.x = <em>"String.leftPad(<b>this</b>.getDate(), 2, '0')"</em>;(<b>new</b> Date()).format(<em>"X"</em>); // returns the current day of the month</code></pre> </div>
</div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row alt expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.monthNames"></a>
<b>Date.monthNames</b> : Array <div class="mdesc">
<div class="short"><static> An array of textual month names.Override these values for international dates.Example:Date.monthNam...</div>
<div class="long">
<static> An array of textual month names.Override these values for international dates.Example:<pre><code>Date.monthNames = [ <em>'JanInYourLang'</em>, <em>'FebInYourLang'</em>, ...];</code></pre> </div>
</div>
</td>
<td class="msource">Date</td>
</tr>
<tr class="property-row expandable">
<td class="micon"><a class="exi" href="#expand"> </a></td>
<td class="sig">
<a id="Date-Date.monthNumbers"></a>
<b>Date.monthNumbers</b> : Object <div class="mdesc">
<div class="short"><static> An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are ...</div>
<div class="long">
<static> An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are case-sensitive).Override these values for international dates.Example:<pre><code>Date.monthNumbers = { <em>'ShortJanNameInYourLang'</em>:0, <em>'ShortFebNameInYourLang'</em>:1, ...};</code></pre> </div>
</div>
</td>
<td class="msource">Date</td>
</tr>
</table> <a id="Date-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 class="method-row expandable">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?