UTC Method
Returns the number of milliseconds between midnight, January 1, 1970 Coordinated Universal Time (UTC) (or GMT) and the supplied date.
function UTC(year : Number , month : Number , day : Number [, hours : Number [, minutes : Number [, seconds : Number [,ms : Number]]]]) : Number
The UTC method returns the number of milliseconds between midnight, January 1, 1970 UTC and the supplied date. This return value can be used in the setTime method and in the Date object constructor. If the value of an argument is greater than its range, or is a negative number, other stored values are modified accordingly. For example, if you specify 150 seconds, JScript redefines that number as two minutes and 30 seconds.
The difference between the UTC method and the Date object constructor that accepts a date is that the UTC method assumes UTC, and the Date object constructor assumes local time.
The UTC method is a static method. Therefore, a Date object does not have to be created before it can be used.
The following example illustrates the use of the UTC method.
function DaysBetweenDateAndNow(yr, mo, dy)
{
// Determine the milliseconds per day.
var MinMilli = 1000 * 60
var HrMilli = MinMilli * 60
var DyMilli = HrMilli * 24
// Determine today's UTC year, month, and day.
var d = new Date();
var yeartoday = d.getUTCFullYear();
var monthtoday = d.getUTCMonth();
var dayofmonthtoday = d.getUTCDate();
// Get the milliseconds since 1/1/1970 UTC.
var t1 = Date.UTC(yr, mo - 1, dy)
var t2 = Date.UTC(yeartoday, monthtoday, dayofmonthtoday);
// Determine the difference in days.
var days = (t1 - t2) / DyMilli;
return(days);
}