JavaScript getUTCHours Method

The getUTCHours method returns, according to universal time, the hour of the point in time stored in a Date object. The value returned by this method is an integer number from 0 to 23.



With myDate being an object based on the Date object.


The following code uses the getUTCHours method to return the current hour according to universal time:

<script type="text/javascript">

var currentDate = new Date();
var universalCurrentHour = currentDate.getUTCHours();

document.write("According to universal time the current hour is: " + universalCurrentHour + ".");


Technical Details

The getUTCHours method belongs to the Date object, it is available since the version 1.3 of JavaScript, and it is supported in all major browsers.

JavaScript Manual >> Date Object >> getUTCHours Method

© Copyright 2010-2017 ROM Cartridge

How old was John Travolta in Pulp Fiction?