diff options
Diffstat (limited to 'files/zh-tw/web/javascript/reference/global_objects/date')
-rw-r--r-- | files/zh-tw/web/javascript/reference/global_objects/date/prototype/index.html | 246 |
1 files changed, 0 insertions, 246 deletions
diff --git a/files/zh-tw/web/javascript/reference/global_objects/date/prototype/index.html b/files/zh-tw/web/javascript/reference/global_objects/date/prototype/index.html deleted file mode 100644 index 5490743ec0..0000000000 --- a/files/zh-tw/web/javascript/reference/global_objects/date/prototype/index.html +++ /dev/null @@ -1,246 +0,0 @@ ---- -title: Date.prototype -slug: Web/JavaScript/Reference/Global_Objects/Date/prototype -tags: - - Date - - JavaScript - - 原型 - - 參考資料 - - 屬性 -translation_of: Web/JavaScript/Reference/Global_Objects/Date -translation_of_original: Web/JavaScript/Reference/Global_Objects/Date/prototype ---- -<div>{{JSRef}}</div> - -<p><strong><code>Date.prototype</code></strong> 屬性表示 {{jsxref("Date")}} 建構子的原型。</p> - -<div>{{js_property_attributes(0, 0, 1)}}</div> - -<h2 id="描述">描述</h2> - -<p>JavaScript {{jsxref("Date")}} 實體繼承自 <code>Date.prototype。你可以藉由改變建構子的原型物件,來影響所有繼承自</code> JavaScript {{jsxref("Date")}} 的實體。</p> - -<p>為了千年年份(換個說法,考慮現在已到了 2000 年)的相容性,設定上你應該採用完整的年份。舉例來說,使用 1998 而不是 98 。為了讓你能取得完整的年份資料, Javascript 包含了 {{jsxref("Date.prototype.getFullYear()", "getFullYear()")}} , {{jsxref("Date.prototype.setFullYear()", "setFullYear()")}} , {{jsxref("Date.prototype.getUTCFullYear()", "getUTCFullYear()")}} 以及 {{jsxref("Date.prototype.setUTCFullYear()", "setUTCFullYear()")}} 方法。</p> - -<p>自 ECMAScript 6 開始, <code>Date.prototype</code> 物件只是個一般物件,而不是一個 {{jsxref("Date")}} 實體。</p> - -<h2 id="屬性">屬性</h2> - -<dl> - <dt><code>Date.prototype.constructor</code></dt> - <dd>回傳一個能建立實體的函數,這是 {{jsxref("Date")}} 預設的建構子。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<h3 id="Getter">Getter</h3> - -<dl> - <dt>{{jsxref("Date.prototype.getDate()")}}</dt> - <dd>回傳本地時間月份中的日期(1-31)。</dd> - <dt>{{jsxref("Date.prototype.getDay()")}}</dt> - <dd>回傳本地時間星期中的日子(0-6)。</dd> - <dt>{{jsxref("Date.prototype.getFullYear()")}}</dt> - <dd>回傳本地時間的年份( 以 4 位數表現)。</dd> - <dt>{{jsxref("Date.prototype.getHours()")}}</dt> - <dd>回傳本地時間的小時(0-23)。</dd> - <dt>{{jsxref("Date.prototype.getMilliseconds()")}}</dt> - <dd>回傳本地時間的毫秒數(0-999)。</dd> - <dt>{{jsxref("Date.prototype.getMinutes()")}}</dt> - <dd>回傳本地時間的分鐘數(0-59)。</dd> - <dt>{{jsxref("Date.prototype.getMonth()")}}</dt> - <dd>回傳本地時間的月份(0-11)。</dd> - <dt>{{jsxref("Date.prototype.getSeconds()")}}</dt> - <dd>回傳本地時間的秒數(0-59)。</dd> - <dt>{{jsxref("Date.prototype.getTime()")}}</dt> - <dd>回傳由 1970-01-01 00:00:00 UTC 開始,到代表時間經過的毫秒數(以負值表示 1970 年之前的時間)。</dd> - <dt>{{jsxref("Date.prototype.getTimezoneOffset()")}}</dt> - <dd>回傳本地時差為多少分鐘。</dd> - <dt>{{jsxref("Date.prototype.getUTCDate()")}}</dt> - <dd>回傳標準時間的在月份中的日期(1-31)。</dd> - <dt>{{jsxref("Date.prototype.getUTCDay()")}}</dt> - <dd>回傳標準時間在星期中的日子(0-6)。</dd> - <dt>{{jsxref("Date.prototype.getUTCFullYear()")}}</dt> - <dd>回傳標準時間的年份( 以 4 位數表現)。</dd> - <dt>{{jsxref("Date.prototype.getUTCHours()")}}</dt> - <dd>回傳標準時間的小時數(0-23)。</dd> - <dt>{{jsxref("Date.prototype.getUTCMilliseconds()")}}</dt> - <dd>回傳標準時間裡的毫秒數(0-999)。</dd> - <dt>{{jsxref("Date.prototype.getUTCMinutes()")}}</dt> - <dd>回傳標準時間的分鐘數(0-59)。</dd> - <dt>{{jsxref("Date.prototype.getUTCMonth()")}}</dt> - <dd>回傳標準時間的月份數(0-11)。</dd> - <dt>{{jsxref("Date.prototype.getUTCSeconds()")}}</dt> - <dd>回傳標準時間的秒數(0-59)。</dd> - <dt>{{jsxref("Date.prototype.getYear()")}} {{deprecated_inline}}</dt> - <dd>回本地時間的年份(通常 2-3 位數)。用 {{jsxref("Date.prototype.getFullYear()", "getFullYear()")}} 取代。</dd> -</dl> - -<h3 id="Setter">Setter</h3> - -<dl> - <dt>{{jsxref("Date.prototype.setDate()")}}</dt> - <dd>設定本地時間月份中的日期。</dd> - <dt>{{jsxref("Date.prototype.setFullYear()")}}</dt> - <dd>設定本地時間的完整年份(以 4 位數表達 4 位數年份)。</dd> - <dt>{{jsxref("Date.prototype.setHours()")}}</dt> - <dd>設定本地時間的小時數。</dd> - <dt>{{jsxref("Date.prototype.setMilliseconds()")}}</dt> - <dd>設定本地時間的毫秒數。</dd> - <dt>{{jsxref("Date.prototype.setMinutes()")}}</dt> - <dd>設定本地時間的分鐘數。</dd> - <dt>{{jsxref("Date.prototype.setMonth()")}}</dt> - <dd>設定本地時間的月份。</dd> - <dt>{{jsxref("Date.prototype.setSeconds()")}}</dt> - <dd>設定本地時間的秒數。</dd> - <dt>{{jsxref("Date.prototype.setTime()")}}</dt> - <dd>設定這個 {{jsxref("Date")}} 物件距 1970-01-01 00:00:00 UTC 的毫秒數,允許使用負值表示之前的時間。</dd> - <dt>{{jsxref("Date.prototype.setUTCDate()")}}</dt> - <dd>設定標準時間月份中的日期。</dd> - <dt>{{jsxref("Date.prototype.setUTCFullYear()")}}</dt> - <dd>設定標準時間的完整年份(以 4 位數表示 4 位數年分)。</dd> - <dt>{{jsxref("Date.prototype.setUTCHours()")}}</dt> - <dd>設定標準時間的小時數。</dd> - <dt>{{jsxref("Date.prototype.setUTCMilliseconds()")}}</dt> - <dd>設定標準時間的毫秒數。</dd> - <dt>{{jsxref("Date.prototype.setUTCMinutes()")}}</dt> - <dd>設定標準時間的分鐘數。</dd> - <dt>{{jsxref("Date.prototype.setUTCMonth()")}}</dt> - <dd>設定標準時間的月份數。</dd> - <dt>{{jsxref("Date.prototype.setUTCSeconds()")}}</dt> - <dd>設定標準時間的秒數。</dd> - <dt>{{jsxref("Date.prototype.setYear()")}} {{deprecated_inline}}</dt> - <dd>設定本地時間的年份(使用 2-3 位數)。使用 {{jsxref("Date.prototype.setFullYear()", "setFullYear()")}} 取代。</dd> -</dl> - -<h3 id="Conversion_getter">Conversion getter</h3> - -<dl> - <dt>{{jsxref("Date.prototype.toDateString()")}}</dt> - <dd>以可閱讀的字串型式,回傳 {{jsxref("Date")}} 的部分資訊。</dd> - <dt>{{jsxref("Date.prototype.toISOString()")}}</dt> - <dd>將日期時間轉換成 ISO 8601 格式的字串回傳。</dd> - <dt>{{jsxref("Date.prototype.toJSON()")}}</dt> - <dd>回傳等義於 {{jsxref("Date")}} 物件使用 {{jsxref("Date.prototype.toISOString()", "toISOString()")}} 方法的結果。特別使用 {{jsxref("JSON.stringify()")}} 處理。</dd> - <dt>{{jsxref("Date.prototype.toGMTString()")}} {{deprecated_inline}}</dt> - <dd>回傳 {{jsxref("Date")}} 以 GMT (UT) 時區基準代表的時間字串。使用 {{jsxref("Date.prototype.toUTCString()", "toUTCString()")}} 方法來取代。</dd> - <dt>{{jsxref("Date.prototype.toLocaleDateString()")}}</dt> - <dd>依照系統的時間地區設定,回傳日期字串。</dd> - <dt>{{jsxref("Date.prototype.toLocaleFormat()")}} {{non-standard_inline}}</dt> - <dd>傳入格式化字串參數,將日期時間轉換成指定格式的字串。</dd> - <dt>{{jsxref("Date.prototype.toLocaleString()")}}</dt> - <dd>回傳依系統的地區設定導出的日期時間字串。覆寫自 {{jsxref("Object.prototype.toLocaleString()")}} 方法。</dd> - <dt>{{jsxref("Date.prototype.toLocaleTimeString()")}}</dt> - <dd>回傳依系統的地區設定導出的時間字串。</dd> - <dt>{{jsxref("Date.prototype.toSource()")}} {{non-standard_inline}}</dt> - <dd>回傳一個建立相同 {{jsxref("Date")}} 物件的程式碼字串;你可以拿這個結果來建立新物件。覆寫自 {{jsxref("Object.prototype.toSource()")}} 方法。</dd> - <dt>{{jsxref("Date.prototype.toString()")}}</dt> - <dd>回傳代表此 {{jsxref("Date")}} 物件的字串。覆寫自 {{jsxref("Object.prototype.toString()")}} 方法。</dd> - <dt>{{jsxref("Date.prototype.toTimeString()")}}</dt> - <dd>以人類可讀的格式,回傳時間部分的字串。</dd> - <dt>{{jsxref("Date.prototype.toUTCString()")}}</dt> - <dd>依 UTC 時區,轉換出時間日期字串。</dd> - <dt>{{jsxref("Date.prototype.valueOf()")}}</dt> - <dd>回傳 {{jsxref("Date")}} 物件的原始數值。覆寫自 {{jsxref("Object.prototype.valueOf()")}} 方法。</dd> -</dl> - -<h2 id="規範">規範</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">規範</th> - <th scope="col">狀態</th> - <th scope="col">註</th> - </tr> - <tr> - <td>{{SpecName('ES1')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>初步定義。實作在 JavaScript 1.1.</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.9.5', 'Date.prototype')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-properties-of-the-date-prototype-object', 'Date.prototype')}}</td> - <td>{{Spec2('ES6')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-properties-of-the-date-prototype-object', 'Date.prototype')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="瀏覽器相容性">瀏覽器相容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>平台</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>基本支援</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td>一般物件</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop("41")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>平台</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>基本支援</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td>一般物件</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile("41")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> |