Home

# Class goog.date.Date

Class representing a date. Defaults to current date if none is specified. Implements most methods of the native js Date object (except the time related ones, {@see goog.date.DateTime}) and can be used interchangeably with it just as if goog.date.Date was a synonym of Date. To make this more transparent, Closure APIs should accept goog.date.DateLike instead of the real Date object. To allow goog.date.Date objects to be passed as arguments to methods expecting Date objects this class is marked as extending the built in Date object even though that's not strictly true.

Instance Method Summary
| `add(?goog.date.Interval interval)` Performs date calculation by adding the supplied interval to the date.
| `clone() ⇒ !goog.date.Date`
| `equals(?goog.date.Date other) ⇒ boolean` Tests whether given date is equal to this Date. Note: This ignores units more precise than days (hours and below) and also ignores timezone considerations.
| `getDate() ⇒ number`
| `getDay() ⇒ ?goog.date.weekDay`
| `getDayOfYear() ⇒ number`
| `getFirstDayOfWeek() ⇒ number`
| `getFirstWeekCutOffDay() ⇒ number`
| `getFullYear() ⇒ number`
| `getIsoWeekday() ⇒ number`
| `getMonth() ⇒ ?goog.date.month`
| `getNumberOfDaysInMonth() ⇒ number`
| `getTime() ⇒ number` Returns the number of milliseconds since 1 January 1970 00:00:00.
| `getTimezoneOffset() ⇒ number` Returns timezone offset. The timezone offset is the delta in minutes between UTC and your local time. E.g., UTC+10 returns -600. Daylight savings time prevents this value from being constant.
| `getTimezoneOffsetString() ⇒ string` Returns timezone offset as a string. Returns offset in [+-]HH:mm format or Z for UTC.
| `getUTCDate() ⇒ number`
| `getUTCDay() ⇒ ?goog.date.weekDay`
| `getUTCFullYear() ⇒ number`
| `getUTCHours() ⇒ number`
| `getUTCIsoWeekday() ⇒ number`
| `getUTCMinutes() ⇒ number`
| `getUTCMonth() ⇒ ?goog.date.month`
| `getUTCWeekday() ⇒ number`
| `getWeekNumber() ⇒ number`
| `getWeekday() ⇒ number`
| `getYear() ⇒ number` Alias for getFullYear.
| `maybeFixDst_(number expected)` Fixes date to account for daylight savings time in browsers that fail to do so automatically.
| `set(?goog.date.Date date)` Sets the date.
| `setDate(number date)` Sets the day part of the date.
| `setFirstDayOfWeek(number day)` Sets the first day of week.
| `setFirstWeekCutOffDay(number day)` Sets cut off weekday used for week number calculations. 0 = Mon, 6 = Sun.
| `setFullYear(number year)` Sets the year part of the date.
| `setMonth(number month)` Sets the month part of the date. TODO(nnaze): Update type to goog.date.month.
| `setTime(number ms)` Sets the value of the date object as expressed in the number of milliseconds since 1 January 1970 00:00:00.
| `setUTCDate(number date)` Sets the day part of the date according to universal time.
| `setUTCFullYear(number year)` Sets the year part of the date according to universal time.
| `setUTCMonth(number month)` Sets the month part of the date according to universal time.
| `setYear(number year)` Alias for setFullYear.
| `toIsoString(boolean= opt_verbose, boolean= opt_tz) ⇒ string` Returns ISO 8601 string representation of date.
| `toString() ⇒ string` Overloaded toString method for object.
| `toUTCIsoString(boolean= opt_verbose, boolean= opt_tz) ⇒ string` Returns ISO 8601 string representation of date according to universal time.
| `valueOf() ⇒ number`

Static Method Summary
| `compare(!goog.date.DateLike date1, !goog.date.DateLike date2) ⇒ number` Compares two dates. May be used as a sorting function.