Date.setUTCHours()

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

							date.setUTCHours(hours)

Description

The setUTCHours() method sets the hour in the Date object to the argument hours, an integer from 0 (12:00 a.m. midnight) to 23 (11:00 p.m.) universal time. The method returns an integer representing the number of milliseconds between midnight January 1, 1970 (GMT) to the date and time specified in the Date object after the hour has been adjusted.

Example

The code in Listing 6.102 displays the current date in milliseconds (universal time) before setting the hour to 5 (6:00am). Notice that the milliseconds specified after the setUTCHours() method are the same as the result returned from the method.

Listing 6.102 Setting ...

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.