| ★ wanayoo — archive 1999 http://developer.mozilla.org/cn/Core_JavaScript_1.5_Reference/Global_Objects/Date | Nouvelle recherche | Portail wanayoo |
毫秒 日期字符串 年
1998, 而不要用 98.
月
date
hour
minute
second
millisecond
For security reasons, you cannot redeclare this global object starting with JavaScript 1.8.
如果没有指定参数, the constructor creates a Date 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.
The date is measured in milliseconds since midnight 01 January, 1970 UTC. A day holds 86,400,000 milliseconds. The Date object range is -100,000,000 days to 100,000,000 days relative to 01 January, 1970 UTC.
The Date object provides uniform behavior across platforms.
The Date 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.
Invoking Date in a non-constructor context (i.e., without the new operator) will return a string representing the current time.
For properties inherited by Date instances, see Properties of Date instances.
Date增加额外的属性。
Properties inherited from Function.prototype
caller, constructor, length, name
For methods inherited by Date instances, see Methods of Date instances.
Date object since January 1, 1970, 00:00:00, universal time.
Methods inherited from Object.prototype
__defineGetter__, __defineSetter__, hasOwnProperty, isPrototypeOf, __lookupGetter__, __lookupSetter__, __noSuchMethod__, propertyIsEnumerable, unwatch, watch
The following examples show several ways to assign dates:
today = new Date();
birthday = new Date("December 17, 1995 03:24:00");
birthday = new Date(1995,11,17);
birthday = new Date(1995,11,17,3,24,0);
The following examples show how to determine the elapsed time between two dates:
// using static methods var start = Date.now(); // the event you'd like to time goes here: doSomethingForALongTime(); var end = Date.now(); var elapsed = end - start; // time in milliseconds
// if you have Date objects var start = new Date(); // the event you'd like to time goes here: doSomethingForALongTime(); var end = new Date(); var elapsed = end.getTime() - start.getTime(); // time in milliseconds
Page last modified 05:19, 25 Mar 2008 by Mickeyboy