DateTime92
Constructors
fromDateUnsafeconstCreate a DateTime from a Date.makeconstCreates a DateTime safely from supported input values.makeUnsafeconstCreate a DateTime from supported input values.makeZonedconstCreates a DateTime.Zoned safely from an input and a time zone.makeZonedFromStringconstParses an ISO zoned date-time string into a DateTime.Zoned safely.makeZonedUnsafeconstCreate a DateTime.Zoned using DateTime.makeUnsafe and a time zone.nowconstGets the current time using the Clock service and convert it to a DateTime.nowAsDateconstGets the current time from the Clock service and returns it as a JavaScript Date.nowUnsafeconstGets the current time using Date.now.Models
DateTimetypeA DateTime represents a point in time.DisambiguationtypeA Disambiguation is used to resolve ambiguities when a DateTime is ambiguous, such as during a daylight saving time transition.TimeZonetypeRepresents a time zone used by DateTime.Zoned.UtcinterfaceRepresents a DateTime stored as an absolute UTC instant with no associated time zone.ZonedinterfaceRepresents a DateTime with an associated TimeZone.Guards
isDateTimeconstChecks whether a value is a DateTime.isTimeZoneconstChecks whether a value is a TimeZone.isTimeZoneNamedconstChecks whether a value is a named TimeZone (IANA time zone).isTimeZoneOffsetconstChecks whether a value is an offset-based TimeZone.isUtcconstChecks whether a DateTime is a UTC DateTime (no time zone information).isZonedconstChecks whether a DateTime is a zoned DateTime (has time zone information).Mapping
mapEpochMillisconstTransforms a DateTime by applying a function to the number of milliseconds since the Unix epoch.matchconstPattern match on a DateTime to handle Utc and Zoned cases differently.mutateconstModifies a DateTime with a mutable local Date copy.mutateUtcconstModifies a DateTime with a mutable UTC Date copy.withDateconstApplies a function to a JavaScript Date representing the DateTime and returns the function's result.withDateUtcconstApplies a function to a JavaScript Date representing the DateTime's UTC instant and returns the function's result.Comparisons
betweenconstChecks whether a DateTime is between two other DateTime values (inclusive).distanceconstComputes the difference between two DateTime values, returning a Duration representing the amount of time between them.isFutureconstChecks effectfully if a DateTime is in the future compared to the current time.isFutureUnsafeconstChecks synchronously if a DateTime is in the future compared to the current time.isGreaterThanconstChecks whether the first DateTime is after the second DateTime.isGreaterThanOrEqualToconstChecks whether the first DateTime is after or equal to the second DateTime.isLessThanconstChecks whether the first DateTime is before the second DateTime.isLessThanOrEqualToconstChecks whether the first DateTime is before or equal to the second DateTime.isPastconstChecks effectfully if a DateTime is in the past compared to the current time.isPastUnsafeconstChecks synchronously if a DateTime is in the past compared to the current time.maxconstReturns the later of two DateTime values.minconstReturns the earlier of two DateTime values.Converting
removeTimeconstRemoves the time aspect of a DateTime, first adjusting for the time zone.toDateconstConverts a DateTime to a Date, applying the time zone first.toDateUtcconstGets the UTC Date of a DateTime.toEpochMillisconstGets the milliseconds since the Unix epoch of a DateTime.zonedOffsetconstComputes the time zone offset of a DateTime.Zoned in milliseconds.zonedOffsetIsoconstFormats the time zone offset of a DateTime.Zoned as an ISO string.Current Time Zone
CurrentTimeZoneclassContext service that supplies the ambient TimeZone for APIs that work in the current zone, such as DateTime.setZoneCurrent and DateTime.nowInCurrentZone.layerCurrentZoneconstCreate a Layer from the given time zone.layerCurrentZoneLocalconstCreate a Layer from the system's local time zone.layerCurrentZoneNamedconstCreate a Layer from the given IANA time zone identifier.layerCurrentZoneOffsetconstCreate a Layer from the given time zone offset.nowInCurrentZoneconstGets the current time as a DateTime.Zoned, using the CurrentTimeZone.setZoneCurrentconstSets the time zone of a DateTime to the current time zone, which is determined by the CurrentTimeZone service.withCurrentZoneconstProvides the CurrentTimeZone to an effect.withCurrentZoneLocalconstProvides the CurrentTimeZone to an effect, using the system's local time zone.withCurrentZoneNamedconstProvides the CurrentTimeZone to an effect using an IANA time zone identifier.withCurrentZoneOffsetconstProvides the CurrentTimeZone to an effect, using an offset.Formatting
formatconstFormats a DateTime with Intl.DateTimeFormat.formatIntlconstFormats a DateTime as a string using the Intl.DateTimeFormat API.formatIsoconstFormats a DateTime as a UTC ISO string.formatIsoDateconstFormats a DateTime as a time zone adjusted ISO date string.formatIsoDateUtcconstFormats a DateTime as a UTC ISO date string.formatIsoOffsetconstFormats a DateTime.Zoned as an ISO string with an offset.formatIsoZonedconstFormats a DateTime.Zoned as a string.formatLocalconstFormats a DateTime with Intl.DateTimeFormat using the system local time zone and locale.formatUtcconstFormats a DateTime with Intl.DateTimeFormat using the UTC time zone.Instances
Math
addconstAdds the given amount of unit to a DateTime.addDurationconstAdds the given Duration to a DateTime.endOfconstConverts a DateTime to the end of the given part.nearestconstConverts a DateTime to the nearest given part.startOfconstConverts a DateTime to the start of the given part.subtractconstSubtracts the given amount of unit from a DateTime.subtractDurationconstSubtracts the given Duration from a DateTime.Ordering
Parts
getPartconstGets one time-zone-adjusted part of a DateTime as a number.getPartUtcconstGets one UTC part of a DateTime as a number.setPartsconstSets time-zone-adjusted parts on a DateTime.setPartsUtcconstSets UTC parts on a DateTime.toPartsconstGets the time-zone-adjusted parts of a DateTime as an object.toPartsUtcconstGets the UTC parts of a DateTime as an object.Time Zones
setZoneconstSets the time zone of a DateTime, returning a new DateTime.Zoned.setZoneNamedconstSets the time zone of a DateTime safely from an IANA time zone identifier.setZoneNamedUnsafeconstSets the time zone of a DateTime from an IANA time zone identifier.setZoneOffsetconstAdds a fixed offset time zone to a DateTime.toUtcconstConverts a DateTime to a UTC DateTime.zoneFromStringconstTries to parse a TimeZone from a string safely.zoneMakeLocalconstCreate a named time zone from the system's local time zone.zoneMakeNamedconstCreates a named time zone safely from an IANA time zone identifier.zoneMakeNamedEffectconstCreates a named time zone effectfully from an IANA time zone identifier.zoneMakeNamedUnsafeconstAttempts to create a named time zone from an IANA time zone identifier.zoneMakeOffsetconstCreate a fixed offset time zone.zoneToStringconstFormats a TimeZone as a string.