Get to know MDN better
此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
Date 實例的 getHours() 方法會根據本地時間回傳此日期的小時數。
無。
一個介於 0 到 23 之間的整數,表示給定日期根據本地時間的小時。如果日期是無效的,則回傳 NaN。
hours 變數的值為 23,基於 Date 物件 xmas95 的值。
| ECMAScript® 2027 Language Specification # sec-date.prototype.gethours |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年8月6日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.