Date.prototype.getHours()

  • Revision slug: JavaScript/Reference/Global_Objects/Date/getHours
  • Revision title: getHours
  • Revision id: 9005
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment 6 words added, 12 words removed

Revision Content

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

Method of Date
Implemented in 1.0
ECMAScript Edition ECMAScript 1st Edition

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>
<p>Returns the hour for the specified date according to local time.
</p>
<table class="standard-table"> <thead> <tr> <th class="header" colspan="2">Method of <a href="/en/JavaScript/Reference/Global_Objects/Date"><code>Date</code></a></th> </tr> </thead> <tbody> <tr> <td>Implemented in</td> <td>1.0</td> </tr> <tr> <td>ECMAScript Edition</td> <td>ECMAScript 1st Edition</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>
<div class="noinclude">
</div>
{{ 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