mozilla

Revision 9006 of Date.prototype.getHours()

  • Revision slug: JavaScript/Reference/Global_Objects/Date/getHours
  • Revision title: getHours
  • Revision id: 9006
  • Created:
  • Creator: Yuichirou
  • Is current revision? No
  • Comment Reverted to earlier version; 12 words added, 6 words removed

Revision Content

 

Summary

Returns the hour for the specified date according to local time.

Method of Date
Implemented in: JavaScript 1.0, NES 2.0
ECMA Version: ECMA-262

Syntax

getHours()

Parameters

None.

Description

The value returned by getHours is an integer between 0 and 23.

Examples

Example: Using getHours

The second statement below assigns the value 23 to the variable hours, based on the value of the Date object Xmas95.

Xmas95 = new Date("December 25, 1995 23:15:00")
hours = Xmas95.getHours() 

See Also

getUTCHours, setHours

{{ languages( { "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Date/getHours", "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/Date/getHours", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Date/getHours" } ) }}

Revision Source

<p>
 </p>
<h3 name="Summary"> Summary </h3>
<p>Returns the hour for the specified date according to local time.
</p>
<table class="fullwidth-table">
<tbody><tr>
<td class="header" colspan="2">Method of <a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Date">Date</a></td>
</tr>
<tr>
<td>Implemented in:</td>
<td>JavaScript 1.0, NES 2.0</td>
</tr>
<tr>
<td>ECMA Version:</td>
<td>ECMA-262</td>
</tr>
</tbody></table>
<h3 name="Syntax"> Syntax </h3>
<p><code>
getHours()
</code>
</p>
<h3 name="Parameters"> Parameters </h3>
<p>None.
</p>
<h3 name="Description"> Description </h3>
<p>The value returned by <code>getHours</code> is an integer between 0 and 23.
</p>
<h3 name="Examples"> Examples </h3>
<h4 name="Example:_Using_getHours"> Example: Using <code>getHours</code> </h4>
<p>The second statement below assigns the value 23 to the variable <code>hours</code>, based on the value of the <code>Date</code> object <code>Xmas95</code>.
</p>
<pre>Xmas95 = new Date("December 25, 1995 23:15:00")
hours = Xmas95.getHours() 
</pre>
<h3 name="See_Also"> See Also </h3>
<p><a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Date/getUTCHours">getUTCHours</a>,
<a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Date/setHours">setHours</a>
</p>

{{ languages( { "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Date/getHours", "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/Date/getHours", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Date/getHours" } ) }}
Revert to this revision