Date.getUTCHours()

JavaScript 1.2+, ECMAScript 1.0+, JScript 3.0+ Nav4+, IE 4+ Syntax

							date.getUTCHours()

Description

The getUTCHours() method returns the hour portion of the date expressed, converted to universal time and expressed as an integer from 0 (12:00 a.m. midnight) to 23 (11:00 p.m.).

Example

The code in Listing 6.84 displays the current hour in universal time using the getUTCHours() method.

Listing 6.84 Using the getUTCHours() Method to Return the Current Hour
<html>

<script language="JavaScript">
<!-- Hide
							
							

//Create a Date object that contains the current date and time.
theDate = new Date();

//Display the hour
document.write("The UTC hour is ",theDate.getUTCHours());

//Hide End -->
</script>

</html>
							
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.