From the Definitive Guide (4th Ed.):
Quote:
Date.UTC() is a static method; it is invoked through the Date() constructor, not through an individual Date object.
...
To create a Date object using a UTC time specification, you can use code like this:
d = new Date(Date.UTC(1996, 4, 8, 16, 30));
|
Basically, it's not something where you can say
Code:
var myDate = new Date();
myDate.UTC()
and have it do anything good.
The Date.UTC() method requires arguments to work properly; passing it the arguments from
this effectively makes
Code:
return Date.UTC(
this.getFullYear(),
this.getMonth(),
this.getDate(),
this.getHours(),
this.getMinutes(),
this.getSeconds(),
this.getMilliseconds()
);
act on the specific date object.
You should note that the method is collapsible to three lines, including a line for the close brace. I split each argument onto its own line for readability and to prevent side-scrolling in normal-sized windows.