The goog.date.UtcDateTime Class

goog.date.UtcDateTime
> goog.date.DateTime
> goog.date.Date

goog.date.UtcDateTime(opt_year, opt_month, opt_date, opt_hours, opt_minutes, opt_seconds, opt_milliseconds)

Class representing a date/time in GMT+0 time zone, without daylight saving. Defaults to current date and time if none is specified. The get... and the getUTC... methods are equivalent.

opt_year {number|Object=}
Four digit UTC year or a date-like object. If not set, the created object will contain the date determined by goog.now().
opt_month {number=}
UTC month, 0 = Jan, 11 = Dec.
opt_date {number=}
UTC date of month, 1 - 31.
opt_hours {number=}
UTC hours, 0 - 23.
opt_minutes {number=}
UTC minutes, 0 - 59.
opt_seconds {number=}
UTC seconds, 0 - 59.
opt_milliseconds {number=}
UTC milliseconds, 0 - 999.

.add(interval)

Performs date calculation by adding the supplied interval to the date.

interval {goog.date.Interval}
Date interval to add.

.clone()

Clones the UtcDateTime object.

returns {!goog.date.UtcDateTime}
A clone of the datetime object.

.equals(other)

Inherited from goog.date.DateTime .

Tests whether given datetime is exactly equal to this DateTime.

other {goog.date.Date}
The datetime to compare.
returns {boolean}
Whether the given datetime is exactly equal to this one.

.fromIsoString(formatted)

Creates a DateTime from a UTC datetime string expressed in ISO 8601 format.

formatted {string}
A date or datetime expressed in ISO 8601 format.
returns {goog.date.UtcDateTime}
Parsed date or null if parse fails.

.getDate

.getDay

.getDayOfYear()

Inherited from goog.date.Date .

returns {number}
The day of year.

.getFirstDayOfWeek()

Inherited from goog.date.Date .

returns {number}
The first day of the week. 0 = Mon, 6 = Sun.

.getFirstWeekCutOffDay()

Inherited from goog.date.Date .

returns {number}
The cut off weekday used for week number calculations. 0 = Mon, 6 = Sun.

.getFullYear

.getHours

Returns the hours part of the datetime.

returns {number}
An integer between 0 and 23, representing the hour.

.getIsoWeekday()

Inherited from goog.date.Date .

returns {number}
The day of week, ISO style. 0 = Mon, 6 = Sun.

.getMilliseconds

Returns the milliseconds part of the datetime.

returns {number}
An integer between 0 and 999, representing the milliseconds.

.getMinutes

Returns the minutes part of the datetime.

returns {number}
An integer between 0 and 59, representing the minutes.

.getMonth

.getNumberOfDaysInMonth()

Inherited from goog.date.Date .

returns {number}
The number of days for the selected month.

.getSeconds

Returns the seconds part of the datetime.

returns {number}
An integer between 0 and 59, representing the seconds.

.getTime()

Inherited from goog.date.Date .

Returns the number of milliseconds since 1 January 1970 00:00:00.

returns {number}
The number of milliseconds since 1 January 1970 00:00:00.

.getTimezoneOffset()

.getTimezoneOffsetString()

Inherited from goog.date.Date .

Returns timezone offset as a string. Returns offset in [+-]HH:mm format or Z for UTC.

returns {string}
The timezone offset as a string.

.getUTCDate()

Inherited from goog.date.Date .

returns {number}
The date of month according to universal time.

.getUTCDay()

Inherited from goog.date.DateTime .

Returns the day of week according to universal time, US style.

returns {goog.date.weekDay}
Day of week, 0 = Sun, 1 = Mon, 6 = Sat.

.getUTCFullYear()

Inherited from goog.date.Date .

returns {number}
The four digit year of date according to universal time.

.getUTCHours()

Inherited from goog.date.DateTime .

Returns the hours part of the datetime according to universal time.

returns {number}
An integer between 0 and 23, representing the hour.

.getUTCIsoWeekday()

Inherited from goog.date.Date .

returns {number}
The day of week according to universal time, ISO style. 0 = Mon, 6 = Sun.

.getUTCMilliseconds()

Inherited from goog.date.DateTime .

Returns the milliseconds part of the datetime according to universal time.

returns {number}
An integer between 0 and 999, representing the milliseconds.

.getUTCMinutes()

Inherited from goog.date.DateTime .

Returns the minutes part of the datetime according to universal time.

returns {number}
An integer between 0 and 59, representing the minutes.

.getUTCMonth()

Inherited from goog.date.Date .

returns {goog.date.month}
The month of date according to universal time, 0 = Jan, 11 = Dec.

.getUTCSeconds()

Inherited from goog.date.DateTime .

Returns the seconds part of the datetime according to universal time.

returns {number}
An integer between 0 and 59, representing the seconds.

.getUTCWeekday()

Inherited from goog.date.Date .

returns {number}
The day of week according to universal time and firstDayOfWeek setting.

.getWeekNumber()

Inherited from goog.date.Date .

returns {number}
The week number.

.getWeekday()

Inherited from goog.date.Date .

returns {number}
The day of week according to firstDayOfWeek setting.

.getYear()

Inherited from goog.date.Date .

Alias for getFullYear.

returns {number}
The four digit year of date.
@see
#getFullyear

.set(date)

Inherited from goog.date.Date .

Sets the date.

date {goog.date.Date}
Date object to set date from.

.setDate

.setFirstDayOfWeek(day)

Inherited from goog.date.Date .

Sets the first day of week.

day {number}
0 = Mon, 6 = Sun.

.setFirstWeekCutOffDay(day)

Inherited from goog.date.Date .

Sets cut off weekday used for week number calculations. 0 = Mon, 6 = Sun.

day {number}
The cut off weekday.

.setFullYear

.setHours

Sets the hours part of the datetime.

hours {number}
An integer between 0 and 23, representing the hour.

.setMilliseconds

Sets the seconds part of the datetime.

ms {number}
Integer between 0 and 999, representing the milliseconds.

.setMinutes

Sets the minutes part of the datetime.

minutes {number}
Integer between 0 and 59, representing the minutes.

.setMonth

.setSeconds

Sets the seconds part of the datetime.

seconds {number}
Integer between 0 and 59, representing the seconds.

.setTime(ms)

Inherited from goog.date.Date .

Sets the value of the date object as expressed in the number of milliseconds since 1 January 1970 00:00:00.

ms {number}
Number of milliseconds since 1 Jan 1970.

.setUTCDate(date)

Inherited from goog.date.Date .

Sets the day part of the date according to universal time.

date {number}
The UTC date.

.setUTCFullYear(year)

Inherited from goog.date.Date .

Sets the year part of the date according to universal time.

year {number}
Four digit year.

.setUTCHours(hours)

Inherited from goog.date.DateTime .

Sets the hours part of the datetime according to universal time.

hours {number}
An integer between 0 and 23, representing the hour.

.setUTCMilliseconds(ms)

Inherited from goog.date.DateTime .

Sets the seconds part of the datetime according to universal time.

ms {number}
Integer between 0 and 999, representing the milliseconds.

.setUTCMinutes(minutes)

Inherited from goog.date.DateTime .

Sets the minutes part of the datetime according to universal time.

minutes {number}
Integer between 0 and 59, representing the minutes.

.setUTCMonth(month)

Inherited from goog.date.Date .

Sets the month part of the date according to universal time.

month {number}
The month, where 0 = Jan, 11 = Dec.

.setUTCSeconds(seconds)

Inherited from goog.date.DateTime .

Sets the seconds part of the datetime according to universal time.

seconds {number}
Integer between 0 and 59, representing the seconds.

.setYear(year)

Inherited from goog.date.Date .

Alias for setFullYear.

year {number}
Four digit year.
@see
#setFullYear

.toIsoString(opt_verbose, opt_tz)

Inherited from goog.date.DateTime .

Returns ISO 8601 string representation of date/time.

opt_verbose {boolean=}
Whether the verbose format should be used instead of the default compact one.
opt_tz {boolean=}
Whether the timezone offset should be included in the string.
returns {string}
ISO 8601 string representation of date/time.

.toIsoTimeString(opt_showSeconds)

Inherited from goog.date.DateTime .

Generates time label for the datetime in standard ISO 24-hour time format. E.g., '06:00:00' or '23:30:15'.

opt_showSeconds {boolean=}
Whether to shows seconds. Defaults to TRUE.
returns {string}
The time label.

.toString()

Inherited from goog.date.DateTime .

Overloaded toString method for object.

returns {string}
ISO 8601 string representation of date/time.

.toUTCIsoString(opt_verbose, opt_tz)

Inherited from goog.date.DateTime .

Returns ISO 8601 string representation of date/time according to universal time.

opt_verbose {boolean=}
Whether the opt_verbose format should be returned instead of the default compact one.
opt_tz {boolean=}
Whether the the timezone offset should be included in the string.
returns {string}
ISO 8601 string representation of date/time according to universal time.

.toUsTimeString(opt_padHours, opt_showAmPm, opt_omitZeroMinutes)

Inherited from goog.date.DateTime .

Generates time label for the datetime, e.g., '5:30am'. By default this does not pad hours (e.g., to '05:30') and it does add an am/pm suffix. TODO(user): i18n -- hardcoding time format like this is bad. E.g., in CJK locales, need Chinese characters for hour and minute units.

opt_padHours {boolean=}
Whether to pad hours, e.g., '05:30' vs '5:30'.
opt_showAmPm {boolean=}
Whether to show the 'am' and 'pm' suffix.
opt_omitZeroMinutes {boolean=}
E.g., '5:00pm' becomes '5pm', but '5:01pm' remains '5:01pm'.
returns {string}
The time label.

.toXmlDateTime(opt_timezone)

Inherited from goog.date.DateTime .

Returns XML Schema 2 string representation of date/time. The return value is also ISO 8601 compliant.

opt_timezone {boolean=}
Should the timezone offset be included in the string?.
returns {string}
XML Schema 2 string representation of date/time.

.valueOf()

Inherited from goog.date.Date .

returns {number}
Value of wrapped date.