JavaScript Reference
d.toUTCString() //Returns "Fri, 09 Jan 2015 15:12:22 GMT"
UTC() //Static method
Syntax:
Date.UTC(year , month [, day [, hrs [, mins [, secs [, millis ]]]]])
This is a static method that converts the specified universal time to the milliseconds
since the UNIX ep och. Because the method is static, it is invoked directly thr ough the
Date object itself, rather than through individual Date ob je ct instances. For th e de-
scription of arguments, see the table summarizing the Date() constructor arguments
on page 384. Note that square brackets should not be used in a method. They just
indicate which arguments are optional.
Although the Date.UTC() static method an d the Date() constructor can accept the
same parameters and transform the m to a single number of milliseconds since the
UNIX epoch, there are two important differences between them: First, Date() cre-
ates a Date object, while Date.UTC() only returns an integer. Second, the argu-
ments passed to Date() are under sto od to specify lo cal time, and arguments passed
to Date.UTC() are assumed to represent universal time. By combining Date() and
Date.UTC(), y ou can easily create a Date object using universal time:
//Creates a Date object set to 2 p.m. on August 1, 2016 (UTC):
var dt = new Date(Date.UTC(2016, 7, 1, 14));
valueOf()
Syntax:
date .valueOf()
Returns the same millisecond value as the ge tTime() method.
E.7 document (Client-Side JavaScript)
Every web page that is loaded in a browser owns one Document object accessible
through the global document property. Document implements an interface that acts
as an entry point into th e content of the web p age. Many of the Docume nt’s prop-
erties and methods offer access to elements and other important objects contained in
the docum ent. Apart f rom that, the Document object defines a number of so-called
“factory methods” used for creating elements and other relevant objects.
Technically, a Document object is a subclass of Node. That means that it in herits all
the properties and methods of Node, which you can use in additio n to the Document’s
own properties and methods described in this section. Note that a Document itself
E.7. document (Client-Side JavaScript) 391