?? date.html
字號:
<HTML><HEAD> <META NAME="keywords" CONTENT="electronic commerce, ecommerce, ebusiness, e-business, e-commerce, enterprise software, net economy, Netscape, Sun Microsystems, Sun-Netscape Alliance, iPlanet, internet software"> <META NAME="description" CONTENT="The Sun-Netscape Alliance, a strategic alliance formed by America Online and Sun Microsystems, Inc., is delivering iPlanet e-commerce software and enterprise solutions that enable companies to compete successfully in the Net Economy"> <META HTTP-EQUIV="Content-Type" content="text/html; charset=ISO-8859-1"> <META NAME="TEMPLATEBASE" CONTENT="Authored in FrameMaker. Converted to HTML in WebWorks Publisher 2000. manual wdt 1.5"> <META NAME="LASTUPDATED" CONTENT="09/28/00 13:15:15"> <TITLE> Core JavaScript Reference 1.5: </TITLE></HEAD><BODY TEXT="#000000" LINK="#666699" VLINK="#666699" ALINK="#333366" BGCOLOR="#FFFFFF"><MAINCONTENT><NAVIGATIONCONTENT> <TABLE WIDTH="100%" BORDER="0" CELLSPACING="4"> <TR> <TD VALIGN="TOP"> <b><a href="boolean.html"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Previous</a></FONT> </b><a href="contents.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Contents</a></FONT></b> <a href="ix.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Index</a></FONT></b> <a href="function.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Next</a></FONT></b> </TD> </TR> <TR> <TD VALIGN="TOP" ALIGN="RIGHT" BGCOLOR="#CCCCCC"> <FONT FACE="Arial, Helvetica, sans-serif" COLOR="#000000" SIZE="2"><B> Core JavaScript Reference 1.5</B></FONT> </TD> </TR> <TR> </TABLE> <BR></NAVIGATIONCONTENT><BOOKCONTENT> <blockquote><BR><BR> <BR><BR><P><A NAME="1193137"> </A><A NAME="Date"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="5"><B><zrefhead1>Date</zrefhead1></B></FONT><P><A NAME="1193174"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Lets you work with dates and times.<BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B></B></FONT><BR><BR> <TR> <TD VALIGN=TOP COLSPAN=2 ROWSPAN=1><P><A NAME="1193141"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext><I>Core object</I></ztabletext></FONT></TD> </TR> <TR> <TD VALIGN=TOP><P><A NAME="1193145"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext><I>Implemented in</I></ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1193147"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>JavaScript 1.0, NES 2.0</ztabletext></FONT><P><A NAME="1199402"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext></ztabletext></FONT><P><A NAME="1199452"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>JavaScript 1.1: added <FONT FACE="courier, couriernew, monospaced size">prototype</FONT> property.</ztabletext></FONT><P><A NAME="1193149"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext></ztabletext></FONT><P><A NAME="1199455"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>JavaScript 1.3: removed platform dependencies to provide a uniform behavior across platforms; added <FONT FACE="courier, couriernew, monospaced size">ms_num</FONT> parameter to <FONT FACE="courier, couriernew, monospaced size">Date</FONT> constructor; added <FONT FACE="courier, couriernew, monospaced size"><A HREF="date.html#1193607" >getFullYear</A></FONT>, <FONT FACE="courier, couriernew, monospaced size"><A HREF="date.html#1194264" >setFullYear</A></FONT>, <FONT FACE="courier, couriernew, monospaced size"><A HREF="date.html#1193677" >getMilliseconds</A></FONT>, <FONT FACE="courier, couriernew, monospaced size"><A HREF="date.html#1194367" >setMilliseconds</A></FONT>, <FONT FACE="courier, couriernew, monospaced size"><A HREF="date.html#1195016" >toSource</A></FONT>, and UTC methods (such as <FONT FACE="courier, couriernew, monospaced size"><A HREF="date.html#1219395" >getUTCDate</A></FONT> and <FONT FACE="courier, couriernew, monospaced size"><A HREF="date.html#1194580" >setUTCDate</A></FONT>).</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><P><A NAME="1202749"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext><I>ECMA version</I></ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1202751"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>ECMA-262</ztabletext></FONT> </TD> </TR></TABLE><P></zparagraph></FONT><P><BR><A NAME="1193175"> </A><A NAME="Created by"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Created by</zrefheader></B></FONT><BR><A NAME="1193176"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">Date</FONT> constructor:</zparagraph></FONT><P><A NAME="1193177"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>new Date()<br>new Date(<I>milliseconds</I>)<br>new Date(<I>dateString</I>)<br>new Date(<I>yr_num</I>, <I>mo_num</I>, <I>day_num<br></I> [, <I>hr_num</I>, <I>min_num</I>, <I>sec_num</I>, <I>ms_num</I>])</zcodeline></FONT><P><A NAME="1213308"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><I>Versions prior to JavaScript 1.3:</I></zparagraph></FONT><P><A NAME="1212298"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>new Date()<br>new Date(<I>milliseconds</I>)<br>new Date(<I>dateString</I>)<br>new Date(<I>yr_num</I>, <I>mo_num</I>, <I>day_num</I>[, <I>hr_num</I>, <I>min_num</I>, <I>sec_num</I>])</zcodeline></FONT><P><BR><A NAME="1193178"> </A><A NAME="Parameters"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Parameters</zrefheader></B></FONT><BR><A NAME="1193192"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B></B></FONT><BR><BR> <TR> <TD VALIGN=TOP><A NAME="1212730"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>milliseconds</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1212732"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Integer value representing the number of milliseconds since 1 January 1970 00:00:00.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1193181"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>dateString</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1193183"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>String value representing a date. The string should be in a format recognized by the <A HREF="date.html#1194184" >Date.parse</A> method.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1193185"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>yr_num, mo_num,<br>day_num</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1193187"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Integer values representing part of a date. As an integer value, the month is represented by 0 to 11 with 0=January and 11=December.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1193189"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>hr_num, min_num,<br>sec_num, ms_num</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1193191"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Integer values representing part of a date.</ztabletext></FONT> </TD> </TR></TABLE><P></zparagraph></FONT><P><BR><A NAME="1193193"> </A><A NAME="Description"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Description</zrefheader></B></FONT><BR><A NAME="1193194"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If you supply no arguments, the constructor creates a <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object for today's date and time according to local time. If you supply some arguments but not others, the missing arguments are set to 0. If you supply any arguments, you must supply at least the year, month, and day. You can omit the hours, minutes, seconds, and milliseconds.</zparagraph></FONT><P><A NAME="1213241"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The date is measured in milliseconds since midnight 01 January, 1970 UTC. A day holds 86,400,000 milliseconds. The <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object range is -100,000,000 days to 100,000,000 days relative to 01 January, 1970 UTC.</zparagraph></FONT><P><A NAME="1213242"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object provides uniform behavior across platforms.</zparagraph></FONT><P><A NAME="1193198"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where JavaScript is executed.</zparagraph></FONT><P><A NAME="1213264"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For compatibility with millennium calculations (in other words, to take into account the year 2000), you should always specify the year in full; for example, use 1998, not 98. To assist you in specifying the complete year, JavaScript includes the methods <FONT FACE="courier, couriernew, monospaced size">getFullYear</FONT>, <FONT FACE="courier, couriernew, monospaced size">setFullYear</FONT>, <FONT FACE="courier, couriernew, monospaced size">getFullUTCYear</FONT>, and <FONT FACE="courier, couriernew, monospaced size">setFullUTCYear</FONT>.</zparagraph></FONT><P><A NAME="1193200"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following example returns the time elapsed between <FONT FACE="courier, couriernew, monospaced size">timeA</FONT> and <FONT FACE="courier, couriernew, monospaced size">timeB</FONT> in milliseconds.</zparagraph></FONT><P><A NAME="1209196"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>timeA = new Date();<br>// Statements here to take some action.<br>timeB = new Date();<br>timeDifference = timeB - timeA;</zcodeline></FONT><P><BR><A NAME="1211485"> </A><A NAME="Backward Compatibility"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Backward Compatibility</zrefheader></B></FONT><BR><P><A NAME="1211486"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zheadrunin>JavaScript 1.2 and earlier. </zheadrunin></B></FONT><A NAME="1211487"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object behaves as follows:</zparagraph></FONT><P><ul><A NAME="1211488"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B> <li></B><zsmartlist1>Dates prior to 1970 are not allowed.</zsmartlist1></FONT><P><A NAME="1211489"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B> <li></B><zsmartlist1>JavaScript depends on platform-specific date facilities and behavior; the behavior of the <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object varies from platform to platform.</zsmartlist1></FONT><P></ul><BR><A NAME="1193203"> </A><A NAME="Property Summary"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Property Summary</zrefheader></B></FONT><BR><A NAME="1193216"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B></B></FONT><BR><BR> <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1193206"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Property</ztablehead></B></FONT></TH> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1193208"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Description</ztablehead></B></FONT></TH> </DIV></TR> <TR> <TD VALIGN=TOP><A NAME="1209910"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline><A HREF="date.html#1209532" >constructor</A></zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1209912"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Specifies the function that creates an object's prototype.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1193213"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline><A HREF="date.html#1197095" >prototype</A></zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1193215"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Allows the addition of properties to a <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object.</ztabletext></FONT> </TD> </TR></TABLE><P></zparagraph></FONT><P><BR><A NAME="1193217"> </A><A NAME="Method Summary"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Method Summary</zrefheader></B></FONT><BR><A NAME="1193510"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B></B></FONT><BR><BR> <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1193220"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Method</ztablehead></B></FONT></TH> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1193222"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Description</ztablehead></B></FONT></TH> </DIV></TR> <TR> <TD VALIGN=TOP><A NAME="1193227"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline><A HREF="date.html#1193537" >getDate</A></zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1193229"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Returns the day of the month for the specified date according to local time.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1193234"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline><A HREF="date.html#1193573" >getDay</A></zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1193236"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Returns the day of the week for the specified date according to local time.</ztabletext>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -