moment.github.io
Open in
urlscan Pro
2606:50c0:8002::153
Public Scan
URL:
https://moment.github.io/luxon/api-docs/index.html
Submission: On January 12 via manual from TW — Scanned from DE
Submission: On January 12 via manual from TW — Scanned from DE
Form analysis
0 forms found in the DOMText Content
LUXON 3.2.1 * DateTime ▸ * Static members * .now * .local * .utc * .fromJSDate * .fromMillis * .fromSeconds * .fromObject * .fromISO * .fromRFC2822 * .fromHTTP * .fromFormat * .fromString * .fromSQL * .invalid * .isDateTime * .parseFormatForOpts * .expandFormat * .min * .max * .fromFormatExplain * .fromStringExplain * .DATE_SHORT * .DATE_MED * .DATE_MED_WITH_WEEKDAY * .DATE_FULL * .DATE_HUGE * .TIME_SIMPLE * .TIME_WITH_SECONDS * .TIME_WITH_SHORT_OFFSET * .TIME_WITH_LONG_OFFSET * .TIME_24_SIMPLE * .TIME_24_WITH_SECONDS * .TIME_24_WITH_SHORT_OFFSET * .TIME_24_WITH_LONG_OFFSET * .DATETIME_SHORT * .DATETIME_SHORT_WITH_SECONDS * .DATETIME_MED * .DATETIME_MED_WITH_SECONDS * .DATETIME_MED_WITH_WEEKDAY * .DATETIME_FULL * .DATETIME_FULL_WITH_SECONDS * .DATETIME_HUGE * .DATETIME_HUGE_WITH_SECONDS * Instance members * #get * #isValid * #invalidReason * #invalidExplanation * #locale * #numberingSystem * #outputCalendar * #zone * #zoneName * #year * #quarter * #month * #day * #hour * #minute * #second * #millisecond * #weekYear * #weekNumber * #weekday * #ordinal * #monthShort * #monthLong * #weekdayShort * #weekdayLong * #offset * #offsetNameShort * #offsetNameLong * #isOffsetFixed * #isInDST * #isInLeapYear * #daysInMonth * #daysInYear * #weeksInWeekYear * #resolvedLocaleOptions * #toUTC * #toLocal * #setZone * #reconfigure * #setLocale * #set * #plus * #minus * #startOf * #endOf * #toFormat * #toLocaleString * #toLocaleParts * #toISO * #toISODate * #toISOWeekDate * #toISOTime * #toRFC2822 * #toHTTP * #toSQLDate * #toSQLTime * #toSQL * #toString * #valueOf * #toMillis * #toSeconds * #toUnixInteger * #toJSON * #toBSON * #toObject * #toJSDate * #diff * #diffNow * #until * #hasSame * #equals * #toRelative * #toRelativeCalendar * Duration ▸ * Static members * .fromMillis * .fromObject * .fromDurationLike * .fromISO * .fromISOTime * .invalid * .isDuration * Instance members * #locale * #numberingSystem * #toFormat * #toHuman * #toObject * #toISO * #toISOTime * #toJSON * #toString * #toMillis * #valueOf * #plus * #minus * #mapUnits * #get * #set * #reconfigure * #as * #normalize * #rescale * #shiftTo * #shiftToAll * #negate * #years * #quarters * #months * #weeks * #days * #hours * #minutes * #seconds * #milliseconds * #isValid * #invalidReason * #invalidExplanation * #equals * Interval ▸ * Static members * .invalid * .fromDateTimes * .after * .before * .fromISO * .isInterval * .merge * .xor * Instance members * #start * #end * #isValid * #invalidReason * #invalidExplanation * #length * #count * #hasSame * #isEmpty * #isAfter * #isBefore * #contains * #set * #splitAt * #splitBy * #divideEqually * #overlaps * #abutsStart * #abutsEnd * #engulfs * #equals * #intersection * #union * #difference * #toString * #toLocaleString * #toISO * #toISODate * #toISOTime * #toFormat * #toDuration * #mapEndpoints * Info ▸ * Static members * .hasDST * .isValidIANAZone * .normalizeZone * .months * .monthsFormat * .weekdays * .weekdaysFormat * .meridiems * .eras * .features * Zone ▸ * Instance members * #type * #name * #isUniversal * #offsetName * #formatOffset * #offset * #equals * #isValid * FixedOffsetZone ▸ * Static members * .utcInstance * .instance * .parseSpecifier * Instance members * #type * #name * #offsetName * #formatOffset * #isUniversal * #offset * #equals * #isValid * IANAZone ▸ * Static members * .create * .resetCache * .isValidSpecifier * .isValidZone * Instance members * #type * #name * #isUniversal * #offsetName * #formatOffset * #offset * #equals * #isValid * InvalidZone ▸ * Instance members * #type * #name * #isUniversal * #offsetName * #formatOffset * #offset * #equals * #isValid * SystemZone ▸ * Static members * .instance * Instance members * #type * #name * #isUniversal * #offsetName * #formatOffset * #offset * #equals * #isValid * Settings ▸ * Static members * .now * .now * .defaultZone * .defaultZone * .defaultLocale * .defaultLocale * .defaultNumberingSystem * .defaultNumberingSystem * .defaultOutputCalendar * .defaultOutputCalendar * .twoDigitCutoffYear * .twoDigitCutoffYear * .throwOnInvalid * .throwOnInvalid * .resetCaches Need help reading this? DATETIME A DateTime is an immutable data structure representing a specific date and time and accompanying methods. It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them. A DateTime comprises of: * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch. * A time zone. Each instance is considered in the context of a specific zone (by default the local system's zone). * Configuration properties that effect how output strings are formatted, such as locale, numberingSystem, and outputCalendar. Here is a brief overview of the most commonly used functionality it provides: * Creation: To create a DateTime from its components, use one of its factory class methods: DateTime.local, DateTime.utc, and (most flexibly) DateTime.fromObject. To create one from a standard string format, use DateTime.fromISO, DateTime.fromHTTP, and DateTime.fromRFC2822. To create one from a custom string format, use DateTime.fromFormat. To create one from a native JS date, use DateTime.fromJSDate. * Gregorian calendar and time: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through DateTime#toObject), use the DateTime#year, DateTime#month, DateTime#day, DateTime#hour, DateTime#minute, DateTime#second, DateTime#millisecond accessors. * Week calendar: For ISO week calendar attributes, see the DateTime#weekYear, DateTime#weekNumber, and DateTime#weekday accessors. * Configuration See the DateTime#locale and DateTime#numberingSystem accessors. * Transformation: To transform the DateTime into other DateTimes, use DateTime#set, DateTime#reconfigure, DateTime#setZone, DateTime#setLocale, DateTime.plus, DateTime#minus, DateTime#endOf, DateTime#startOf, DateTime#toUTC, and DateTime#toLocal. * Output: To convert the DateTime to other representations, use the DateTime#toRelative, DateTime#toRelativeCalendar, DateTime#toJSON, DateTime#toISO, DateTime#toHTTP, DateTime#toObject, DateTime#toRFC2822, DateTime#toString, DateTime#toLocaleString, DateTime#toFormat, DateTime#toMillis and DateTime#toJSDate. There's plenty others documented below. In addition, for more information on subtler topics like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation. new DateTime(config: any) Parameters config (any) Static Members ▸ now() Create a DateTime for the current instant, in the system's time zone. Use Settings to override these default values if needed. now(): DateTime Returns DateTime: Example DateTime.now().toISO() //~> now in the ISO format ▸ local(year?, month, day, hour, minute, second, millisecond) Create a local DateTime local(year: number?, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): DateTime Parameters year (number?) The calendar year. If omitted (as in, call local() with no arguments), the current time will be used month (number = 1) The month, 1-indexed day (number = 1) The day of the month, 1-indexed hour (number = 0) The hour of the day, in 24-hour time minute (number = 0) The minute of the hour, meaning a number between 0 and 59 second (number = 0) The second of the minute, meaning a number between 0 and 59 millisecond (number = 0) The millisecond of the second, meaning a number between 0 and 999 Returns DateTime: Example DateTime.local() //~> now DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time DateTime.local(2017) //~> 2017-01-01T00:00:00 DateTime.local(2017, 3) //~> 2017-03-01T00:00:00 DateTime.local(2017, 3, 12, { locale: "fr" }) //~> 2017-03-12T00:00:00, with a French locale DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00 DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00 DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10 DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765 ▸ utc(year?, month, day, hour, minute, second, millisecond, options) Create a DateTime in UTC utc(year: number?, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, options: Object): DateTime Parameters year (number?) The calendar year. If omitted (as in, call utc() with no arguments), the current time will be used month (number = 1) The month, 1-indexed day (number = 1) The day of the month hour (number = 0) The hour of the day, in 24-hour time minute (number = 0) The minute of the hour, meaning a number between 0 and 59 second (number = 0) The second of the minute, meaning a number between 0 and 59 millisecond (number = 0) The millisecond of the second, meaning a number between 0 and 999 options (Object) configuration options for the DateTime Name Description options.locale string? a locale to set on the resulting DateTime instance options.outputCalendar string? the output calendar to set on the resulting DateTime instance options.numberingSystem string? the numbering system to set on the resulting DateTime instance Returns DateTime: Example DateTime.utc() //~> now DateTime.utc(2017) //~> 2017-01-01T00:00:00Z DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" }) //~> 2017-03-12T05:45:00Z with a French locale DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr" }) //~> 2017-03-12T05:45:10.765Z with a French locale ▸ fromJSDate(date, options) Create a DateTime from a JavaScript Date object. Uses the default zone. fromJSDate(date: Date, options: Object): DateTime Parameters date (Date) a JavaScript Date object options (Object = {}) configuration options for the DateTime Name Description options.zone (string | Zone) (default 'local') the zone to place the DateTime into Returns DateTime: ▸ fromMillis(milliseconds, options) Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. fromMillis(milliseconds: number, options: Object): DateTime Parameters milliseconds (number) a number of milliseconds since 1970 UTC options (Object = {}) configuration options for the DateTime Name Description options.zone (string | Zone) (default 'local') the zone to place the DateTime into options.locale string? a locale to set on the resulting DateTime instance options.outputCalendar string the output calendar to set on the resulting DateTime instance options.numberingSystem string the numbering system to set on the resulting DateTime instance Returns DateTime: ▸ fromSeconds(seconds, options) Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. fromSeconds(seconds: number, options: Object): DateTime Parameters seconds (number) a number of seconds since 1970 UTC options (Object = {}) configuration options for the DateTime Name Description options.zone (string | Zone) (default 'local') the zone to place the DateTime into options.locale string? a locale to set on the resulting DateTime instance options.outputCalendar string the output calendar to set on the resulting DateTime instance options.numberingSystem string the numbering system to set on the resulting DateTime instance Returns DateTime: ▸ fromObject(obj, opts) Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults. fromObject(obj: Object, opts: Object): DateTime Parameters obj (Object) the object to create the DateTime from Name Description obj.year number a year, such as 1987 obj.month number a month, 1-12 obj.day number a day of the month, 1-31, depending on the month obj.ordinal number day of the year, 1-365 or 366 obj.weekYear number an ISO week year obj.weekNumber number an ISO week number, between 1 and 52 or 53, depending on the year obj.weekday number an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday obj.hour number hour of the day, 0-23 obj.minute number minute of the hour, 0-59 obj.second number second of the minute, 0-59 obj.millisecond number millisecond of the second, 0-999 opts (Object = {}) options for creating this DateTime Name Description opts.zone (string | Zone) (default 'local') interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone() opts.locale string (default 'system'slocale') a locale to set on the resulting DateTime instance opts.outputCalendar string the output calendar to set on the resulting DateTime instance opts.numberingSystem string the numbering system to set on the resulting DateTime instance Returns DateTime: Example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25' DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01' DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06 DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }), DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' }) DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' }) DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13' ▸ fromISO(text, opts) Create a DateTime from an ISO 8601 string fromISO(text: string, opts: Object): DateTime Parameters text (string) the ISO string opts (Object = {}) options to affect the creation Name Description opts.zone (string | Zone) (default 'local') use this zone if no offset is specified in the input string itself. Will also convert the time to this zone opts.setZone boolean (default false) override the zone with a fixed-offset zone specified in the string itself, if it specifies one opts.locale string (default 'system'slocale') a locale to set on the resulting DateTime instance opts.outputCalendar string? the output calendar to set on the resulting DateTime instance opts.numberingSystem string? the numbering system to set on the resulting DateTime instance Returns DateTime: Example DateTime.fromISO('2016-05-25T09:08:34.123') DateTime.fromISO('2016-05-25T09:08:34.123+06:00') DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true}) DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'}) DateTime.fromISO('2016-W05-4') ▸ fromRFC2822(text, opts) Create a DateTime from an RFC 2822 string fromRFC2822(text: string, opts: Object): DateTime Parameters text (string) the RFC 2822 string opts (Object = {}) options to affect the creation Name Description opts.zone (string | Zone) (default 'local') convert the time to this zone. Since the offset is always specified in the string itself, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. opts.setZone boolean (default false) override the zone with a fixed-offset zone specified in the string itself, if it specifies one opts.locale string (default 'system'slocale') a locale to set on the resulting DateTime instance opts.outputCalendar string the output calendar to set on the resulting DateTime instance opts.numberingSystem string the numbering system to set on the resulting DateTime instance Returns DateTime: Example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT') DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600') DateTime.fromRFC2822('25 Nov 2016 13:23 Z') ▸ fromHTTP(text, opts) Create a DateTime from an HTTP header date fromHTTP(text: string, opts: Object): DateTime Parameters text (string) the HTTP header date opts (Object = {}) options to affect the creation Name Description opts.zone (string | Zone) (default 'local') convert the time to this zone. Since HTTP dates are always in UTC, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. opts.setZone boolean (default false) override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, so this option is equivalent to setting the zone option to 'utc', but this option is included for consistency with similar methods. opts.locale string (default 'system'slocale') a locale to set on the resulting DateTime instance opts.outputCalendar string the output calendar to set on the resulting DateTime instance opts.numberingSystem string the numbering system to set on the resulting DateTime instance Returns DateTime: Related https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 Example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT') DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT') DateTime.fromHTTP('Sun Nov 6 08:49:37 1994') ▸ fromFormat(text, fmt, opts) Create a DateTime from an input string and format string. Defaults to en-US if no locale has been specified, regardless of the system's locale. For a table of tokens and their interpretations, see here. fromFormat(text: string, fmt: string, opts: Object): DateTime Parameters text (string) the string to parse fmt (string) the format the string is expected to be in (see the link below for the formats) opts (Object = {}) options to affect the creation Name Description opts.zone (string | Zone) (default 'local') use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone opts.setZone boolean (default false) override the zone with a zone specified in the string itself, if it specifies one opts.locale string (default 'en-US') a locale string to use when parsing. Will also set the DateTime to this locale opts.numberingSystem string the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system opts.outputCalendar string the output calendar to set on the resulting DateTime instance Returns DateTime: ▸ fromString(text, fmt, opts) fromString(text: any, fmt: any, opts: any) Deprecated: use fromFormat instead Parameters text (any) fmt (any) opts (any = {}) ▸ fromSQL(text, opts) Create a DateTime from a SQL date, time, or datetime Defaults to en-US if no locale has been specified, regardless of the system's locale fromSQL(text: string, opts: Object): DateTime Parameters text (string) the string to parse opts (Object = {}) options to affect the creation Name Description opts.zone (string | Zone) (default 'local') use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone opts.setZone boolean (default false) override the zone with a zone specified in the string itself, if it specifies one opts.locale string (default 'en-US') a locale string to use when parsing. Will also set the DateTime to this locale opts.numberingSystem string the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system opts.outputCalendar string the output calendar to set on the resulting DateTime instance Returns DateTime: Example DateTime.fromSQL('2017-05-15') DateTime.fromSQL('2017-05-15 09:12:34') DateTime.fromSQL('2017-05-15 09:12:34.342') DateTime.fromSQL('2017-05-15 09:12:34.342+06:00') DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles') DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true }) DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' }) DateTime.fromSQL('09:12:34.342') ▸ invalid(reason, explanation) Create an invalid DateTime. invalid(reason: DateTime, explanation: string): DateTime Parameters reason (DateTime) simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent explanation (string = null) longer explanation, may include parameters and other useful debugging information Returns DateTime: ▸ isDateTime(o) Check if an object is an instance of DateTime. Works across context boundaries isDateTime(o: object): boolean Parameters o (object) Returns boolean: ▸ parseFormatForOpts(formatOpts, localeOpts) Produce the format string for a set of options parseFormatForOpts(formatOpts: any, localeOpts: any): string Parameters formatOpts (any) localeOpts (any = {}) Returns string: ▸ expandFormat(fmt, localeOpts) Produce the the fully expanded format token for the locale Does NOT quote characters, so quoted tokens will not round trip correctly expandFormat(fmt: any, localeOpts: any): string Parameters fmt (any) localeOpts (any = {}) Returns string: ▸ min(dateTimes) Return the min of several date times min(dateTimes: ...DateTime): DateTime Parameters dateTimes (...DateTime) the DateTimes from which to choose the minimum Returns DateTime: the min DateTime, or undefined if called with no argument ▸ max(dateTimes) Return the max of several date times max(dateTimes: ...DateTime): DateTime Parameters dateTimes (...DateTime) the DateTimes from which to choose the maximum Returns DateTime: the max DateTime, or undefined if called with no argument ▸ fromFormatExplain(text, fmt, options) Explain how a string would be parsed by fromFormat() fromFormatExplain(text: string, fmt: string, options: Object): Object Parameters text (string) the string to parse fmt (string) the format the string is expected to be in (see description) options (Object = {}) options taken by fromFormat() Returns Object: ▸ fromStringExplain(text, fmt, options) fromStringExplain(text: any, fmt: any, options: any) Deprecated: use fromFormatExplain instead Parameters text (any) fmt (any) options (any = {}) ▸ DATE_SHORT DateTime#toLocaleString format like 10/14/1983 DATE_SHORT Type: Object ▸ DATE_MED DateTime#toLocaleString format like 'Oct 14, 1983' DATE_MED Type: Object ▸ DATE_MED_WITH_WEEKDAY DateTime#toLocaleString format like 'Fri, Oct 14, 1983' DATE_MED_WITH_WEEKDAY Type: Object ▸ DATE_FULL DateTime#toLocaleString format like 'October 14, 1983' DATE_FULL Type: Object ▸ DATE_HUGE DateTime#toLocaleString format like 'Tuesday, October 14, 1983' DATE_HUGE Type: Object ▸ TIME_SIMPLE DateTime#toLocaleString format like '09:30 AM'. Only 12-hour if the locale is. TIME_SIMPLE Type: Object ▸ TIME_WITH_SECONDS DateTime#toLocaleString format like '09:30:23 AM'. Only 12-hour if the locale is. TIME_WITH_SECONDS Type: Object ▸ TIME_WITH_SHORT_OFFSET DateTime#toLocaleString format like '09:30:23 AM EDT'. Only 12-hour if the locale is. TIME_WITH_SHORT_OFFSET Type: Object ▸ TIME_WITH_LONG_OFFSET DateTime#toLocaleString format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is. TIME_WITH_LONG_OFFSET Type: Object ▸ TIME_24_SIMPLE DateTime#toLocaleString format like '09:30', always 24-hour. TIME_24_SIMPLE Type: Object ▸ TIME_24_WITH_SECONDS DateTime#toLocaleString format like '09:30:23', always 24-hour. TIME_24_WITH_SECONDS Type: Object ▸ TIME_24_WITH_SHORT_OFFSET DateTime#toLocaleString format like '09:30:23 EDT', always 24-hour. TIME_24_WITH_SHORT_OFFSET Type: Object ▸ TIME_24_WITH_LONG_OFFSET DateTime#toLocaleString format like '09:30:23 Eastern Daylight Time', always 24-hour. TIME_24_WITH_LONG_OFFSET Type: Object ▸ DATETIME_SHORT DateTime#toLocaleString format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is. DATETIME_SHORT Type: Object ▸ DATETIME_SHORT_WITH_SECONDS DateTime#toLocaleString format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is. DATETIME_SHORT_WITH_SECONDS Type: Object ▸ DATETIME_MED DateTime#toLocaleString format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is. DATETIME_MED Type: Object ▸ DATETIME_MED_WITH_SECONDS DateTime#toLocaleString format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is. DATETIME_MED_WITH_SECONDS Type: Object ▸ DATETIME_MED_WITH_WEEKDAY DateTime#toLocaleString format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is. DATETIME_MED_WITH_WEEKDAY Type: Object ▸ DATETIME_FULL DateTime#toLocaleString format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is. DATETIME_FULL Type: Object ▸ DATETIME_FULL_WITH_SECONDS DateTime#toLocaleString format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is. DATETIME_FULL_WITH_SECONDS Type: Object ▸ DATETIME_HUGE DateTime#toLocaleString format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is. DATETIME_HUGE Type: Object ▸ DATETIME_HUGE_WITH_SECONDS DateTime#toLocaleString format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is. DATETIME_HUGE_WITH_SECONDS Type: Object Instance Members ▸ get(unit) Get the value of unit. get(unit: string): number Parameters unit (string) a unit such as 'minute' or 'day' Returns number: Example DateTime.local(2017, 7, 4).get('month'); //=> 7 DateTime.local(2017, 7, 4).get('day'); //=> 4 ▸ isValid Returns whether the DateTime is valid. Invalid DateTimes occur when: * The DateTime was created from invalid calendar information, such as the 13th month or February 30 * The DateTime was created by an operation on another invalid date isValid Type: boolean ▸ invalidReason Returns an error code if this DateTime is invalid, or null if the DateTime is valid invalidReason Type: string ▸ invalidExplanation Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid invalidExplanation Type: string ▸ locale Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime locale Type: string ▸ numberingSystem Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime numberingSystem Type: string ▸ outputCalendar Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime outputCalendar Type: string ▸ zone Get the time zone associated with this DateTime. zone Type: Zone ▸ zoneName Get the name of the time zone. zoneName Type: string ▸ year Get the year year Type: number Example DateTime.local(2017, 5, 25).year //=> 2017 ▸ quarter Get the quarter quarter Type: number Example DateTime.local(2017, 5, 25).quarter //=> 2 ▸ month Get the month (1-12). month Type: number Example DateTime.local(2017, 5, 25).month //=> 5 ▸ day Get the day of the month (1-30ish). day Type: number Example DateTime.local(2017, 5, 25).day //=> 25 ▸ hour Get the hour of the day (0-23). hour Type: number Example DateTime.local(2017, 5, 25, 9).hour //=> 9 ▸ minute Get the minute of the hour (0-59). minute Type: number Example DateTime.local(2017, 5, 25, 9, 30).minute //=> 30 ▸ second Get the second of the minute (0-59). second Type: number Example DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52 ▸ millisecond Get the millisecond of the second (0-999). millisecond Type: number Example DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654 ▸ weekYear Get the week year weekYear Type: number Related https://en.wikipedia.org/wiki/ISO_week_date Example DateTime.local(2014, 12, 31).weekYear //=> 2015 ▸ weekNumber Get the week number of the week year (1-52ish). weekNumber Type: number Related https://en.wikipedia.org/wiki/ISO_week_date Example DateTime.local(2017, 5, 25).weekNumber //=> 21 ▸ weekday Get the day of the week. 1 is Monday and 7 is Sunday weekday Type: number Related https://en.wikipedia.org/wiki/ISO_week_date Example DateTime.local(2014, 11, 31).weekday //=> 4 ▸ ordinal Get the ordinal (meaning the day of the year) ordinal Type: (number | DateTime) Example DateTime.local(2017, 5, 25).ordinal //=> 145 ▸ monthShort Get the human readable short month name, such as 'Oct'. Defaults to the system's locale if no locale has been specified monthShort Type: string Example DateTime.local(2017, 10, 30).monthShort //=> Oct ▸ monthLong Get the human readable long month name, such as 'October'. Defaults to the system's locale if no locale has been specified monthLong Type: string Example DateTime.local(2017, 10, 30).monthLong //=> October ▸ weekdayShort Get the human readable short weekday, such as 'Mon'. Defaults to the system's locale if no locale has been specified weekdayShort Type: string Example DateTime.local(2017, 10, 30).weekdayShort //=> Mon ▸ weekdayLong Get the human readable long weekday, such as 'Monday'. Defaults to the system's locale if no locale has been specified weekdayLong Type: string Example DateTime.local(2017, 10, 30).weekdayLong //=> Monday ▸ offset Get the UTC offset of this DateTime in minutes offset Type: number Example DateTime.now().offset //=> -240 DateTime.utc().offset //=> 0 ▸ offsetNameShort Get the short human name for the zone's current offset, for example "EST" or "EDT". Defaults to the system's locale if no locale has been specified offsetNameShort Type: string ▸ offsetNameLong Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time". Defaults to the system's locale if no locale has been specified offsetNameLong Type: string ▸ isOffsetFixed Get whether this zone's offset ever changes, as in a DST. isOffsetFixed Type: boolean ▸ isInDST Get whether the DateTime is in a DST. isInDST Type: boolean ▸ isInLeapYear Returns true if this DateTime is in a leap year, false otherwise isInLeapYear Type: boolean Example DateTime.local(2016).isInLeapYear //=> true DateTime.local(2013).isInLeapYear //=> false ▸ daysInMonth Returns the number of days in this DateTime's month daysInMonth Type: number Example DateTime.local(2016, 2).daysInMonth //=> 29 DateTime.local(2016, 3).daysInMonth //=> 31 ▸ daysInYear Returns the number of days in this DateTime's year daysInYear Type: number Example DateTime.local(2016).daysInYear //=> 366 DateTime.local(2013).daysInYear //=> 365 ▸ weeksInWeekYear Returns the number of weeks in this DateTime's year weeksInWeekYear Type: number Related https://en.wikipedia.org/wiki/ISO_week_date Example DateTime.local(2004).weeksInWeekYear //=> 53 DateTime.local(2013).weeksInWeekYear //=> 52 ▸ resolvedLocaleOptions(opts) Returns the resolved Intl options for this DateTime. This is useful in understanding the behavior of formatting methods resolvedLocaleOptions(opts: Object): Object Parameters opts (Object = {}) the same options as toLocaleString Returns Object: ▸ toUTC(offset, opts) "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime. Equivalent to DateTime#setZone('utc') toUTC(offset: number, opts: Object): DateTime Parameters offset (number = 0) optionally, an offset from UTC in minutes opts (Object = {}) options to pass to setZone() Returns DateTime: ▸ toLocal() "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime. Equivalent to setZone('local') toLocal(): DateTime Returns DateTime: ▸ setZone(zone, opts) "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime. By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, as with DateTime#plus. You may wish to use DateTime#toLocal and DateTime#toUTC which provide simple convenience wrappers for commonly used zones. setZone(zone: (string | Zone), opts: Object): DateTime Parameters zone ((string | Zone) = 'local') a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. You may also supply an instance of a DateTime#Zone class. opts (Object = {}) options Name Description opts.keepLocalTime boolean (default false) If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this. opts.keepCalendarTime any (default false) Returns DateTime: ▸ reconfigure(properties) "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime. reconfigure(properties: Object): DateTime Parameters properties (Object = {}) the properties to set Name Description properties.locale any properties.numberingSystem any properties.outputCalendar any Returns DateTime: Example DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' }) ▸ setLocale(locale) "Set" the locale. Returns a newly-constructed DateTime. Just a convenient alias for reconfigure({ locale }) setLocale(locale: any): DateTime Parameters locale (any) Returns DateTime: Example DateTime.local(2017, 5, 25).setLocale('en-GB') ▸ set(values) "Set" the values of specified units. Returns a newly-constructed DateTime. You can only set units with this method; for "setting" metadata, see DateTime#reconfigure and DateTime#setZone. set(values: Object): DateTime Parameters values (Object) a mapping of units to numbers Returns DateTime: Example dt.set({ year: 2017 }) dt.set({ hour: 8, minute: 30 }) dt.set({ weekday: 5 }) dt.set({ year: 2005, ordinal: 234 }) ▸ plus(duration) Add a period of time to this DateTime and return the resulting DateTime Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, accounting for DSTs and leap years along the way. Thus, dt.plus({ hours: 24 }) may result in a different time than dt.plus({ days: 1 }) if there's a DST shift in between. plus(duration: (Duration | Object | number)): DateTime Parameters duration ((Duration | Object | number)) The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() Returns DateTime: Example DateTime.now().plus(123) //~> in 123 milliseconds DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes DateTime.now().plus({ days: 1 }) //~> this time tomorrow DateTime.now().plus({ days: -1 }) //~> this time yesterday DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min ▸ minus(duration) Subtract a period of time to this DateTime and return the resulting DateTime See DateTime#plus minus(duration: (Duration | Object | number)): DateTime Parameters duration ((Duration | Object | number)) The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() Returns DateTime: ▸ startOf(unit) "Set" this DateTime to the beginning of a unit of time. startOf(unit: string): DateTime Parameters unit (string) The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. Returns DateTime: Example DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01' DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01' DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00' DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00' ▸ endOf(unit) "Set" this DateTime to the end (meaning the last millisecond) of a unit of time endOf(unit: string): DateTime Parameters unit (string) The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. Returns DateTime: Example DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00' DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00' DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00' DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00' ▸ toFormat(fmt, opts) Returns a string representation of this DateTime formatted according to the specified format string. You may not want this. See DateTime#toLocaleString for a more flexible formatting tool. For a table of tokens and their interpretations, see here. Defaults to en-US if no locale has been specified, regardless of the system's locale. toFormat(fmt: string, opts: Object): string Parameters fmt (string) the format string opts (Object = {}) opts to override the configuration options on this DateTime Returns string: Example DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22' DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22' DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22' DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes' ▸ toLocaleString(formatOpts, opts) Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, such as DateTime.DATE_FULL or DateTime.TIME_SIMPLE. The exact behavior of this method is browser-specific, but in general it will return an appropriate representation of the DateTime in the assigned locale. Defaults to the system's locale if no locale has been specified toLocaleString(formatOpts: any, opts: Object): string Parameters formatOpts (any = Formats.DATE_SHORT) {Object} - Intl.DateTimeFormat constructor options and configuration options opts (Object = {}) opts to override the configuration options on this DateTime Returns string: Related https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat Example DateTime.now().toLocaleString(); //=> 4/20/2017 DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017' DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017' DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022' DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM' DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM' DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20' DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM' DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32' ▸ toLocaleParts(opts) Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output. Defaults to the system's locale if no locale has been specified toLocaleParts(opts: any) Parameters opts (any = {}) {Object} - Intl.DateTimeFormat constructor options, same as toLocaleString . Related https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts Example DateTime.now().toLocaleParts(); //=> [ //=> { type: 'day', value: '25' }, //=> { type: 'literal', value: '/' }, //=> { type: 'month', value: '05' }, //=> { type: 'literal', value: '/' }, //=> { type: 'year', value: '1982' } //=> ] ▸ toISO(opts) Returns an ISO 8601-compliant string representation of this DateTime toISO(opts: Object): string Parameters opts (Object = {}) options Name Description opts.format string (default 'extended') choose between the basic and extended format opts.suppressSeconds boolean (default false) exclude seconds from the format if they're 0 opts.suppressMilliseconds boolean (default false) exclude milliseconds from the format if they're 0 opts.includeOffset boolean (default true) include the offset, such as 'Z' or '-04:00' opts.extendedZone boolean (default false) add the time zone format extension Returns string: Example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z' DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00' DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335' DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400' ▸ toISODate(opts) Returns an ISO 8601-compliant string representation of this DateTime's date component toISODate(opts: Object): string Parameters opts (Object = {}) options Name Description opts.format string (default 'extended') choose between the basic and extended format Returns string: Example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25' DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525' ▸ toISOWeekDate() Returns an ISO 8601-compliant string representation of this DateTime's week date toISOWeekDate(): string Returns string: Example DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2' ▸ toISOTime(opts) Returns an ISO 8601-compliant string representation of this DateTime's time component toISOTime(opts: Object): string Parameters opts (Object = {}) options Name Description opts.suppressMilliseconds boolean (default false) exclude milliseconds from the format if they're 0 opts.suppressSeconds boolean (default false) exclude seconds from the format if they're 0 opts.includeOffset boolean (default true) include the offset, such as 'Z' or '-04:00' opts.includePrefix boolean (default false) include the T prefix opts.extendedZone boolean (default true) add the time zone format extension opts.format string (default 'extended') choose between the basic and extended format Returns string: Example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z' DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z' DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z' DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z' ▸ toRFC2822() Returns an RFC 2822-compatible string representation of this DateTime toRFC2822(): string Returns string: Example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000' DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400' ▸ toHTTP() Returns a string representation of this DateTime appropriate for use in HTTP headers. The output is always expressed in GMT. Specifically, the string conforms to RFC 1123. toHTTP(): string Returns string: Related https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 Example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT' DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT' ▸ toSQLDate() Returns a string representation of this DateTime appropriate for use in SQL Date toSQLDate(): string Returns string: Example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13' ▸ toSQLTime(opts) Returns a string representation of this DateTime appropriate for use in SQL Time toSQLTime(opts: Object): string Parameters opts (Object = {}) options Name Description opts.includeOffset boolean (default true) include the offset, such as 'Z' or '-04:00' opts.includeZone boolean (default false) include the zone, such as 'America/New_York'. Overrides includeOffset. opts.includeOffsetSpace boolean (default true) include the space between the time and the offset, such as '05:15:16.345 -04:00' Returns string: Example DateTime.utc().toSQL() //=> '05:15:16.345' DateTime.now().toSQL() //=> '05:15:16.345 -04:00' DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345' DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York' ▸ toSQL(opts) Returns a string representation of this DateTime appropriate for use in SQL DateTime toSQL(opts: Object): string Parameters opts (Object = {}) options Name Description opts.includeZone boolean (default false) include the zone, such as 'America/New_York'. Overrides includeOffset. opts.includeOffset boolean (default true) include the offset, such as 'Z' or '-04:00' opts.includeOffsetSpace boolean (default true) include the space between the time and the offset, such as '05:15:16.345 -04:00' Returns string: Example DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z' DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00' DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000' DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York' ▸ toString() Returns a string representation of this DateTime appropriate for debugging toString(): string Returns string: ▸ valueOf() Returns the epoch milliseconds of this DateTime. Alias of DateTime#toMillis valueOf(): number Returns number: ▸ toMillis() Returns the epoch milliseconds of this DateTime. toMillis(): number Returns number: ▸ toSeconds() Returns the epoch seconds of this DateTime. toSeconds(): number Returns number: ▸ toUnixInteger() Returns the epoch seconds (as a whole number) of this DateTime. toUnixInteger(): number Returns number: ▸ toJSON() Returns an ISO 8601 representation of this DateTime appropriate for use in JSON. toJSON(): string Returns string: ▸ toBSON() Returns a BSON serializable equivalent to this DateTime. toBSON(): Date Returns Date: ▸ toObject(opts) Returns a JavaScript object with this DateTime's year, month, day, and so on. toObject(opts: any): Object Parameters opts (any = {}) options for generating the object Name Description opts.includeConfig boolean (default false) include configuration attributes in the output Returns Object: Example DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 } ▸ toJSDate() Returns a JavaScript Date equivalent to this DateTime. toJSDate(): Date Returns Date: ▸ diff(otherDateTime, unit, opts) Return the difference between two DateTimes as a Duration. diff(otherDateTime: DateTime, unit: (string | Array<string>), opts: Object): Duration Parameters otherDateTime (DateTime) the DateTime to compare this one to unit ((string | Array<string>) = ['milliseconds']) the unit or array of units (such as 'hours' or 'days') to include in the duration. opts (Object = {}) options that affect the creation of the Duration Name Description opts.conversionAccuracy string (default 'casual') the conversion system to use Returns Duration: Example var i1 = DateTime.fromISO('1982-05-25T09:45'), i2 = DateTime.fromISO('1983-10-14T10:30'); i2.diff(i1).toObject() //=> { milliseconds: 43807500000 } i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 } i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 } i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 } ▸ diffNow(unit, opts) Return the difference between this DateTime and right now. See DateTime#diff diffNow(unit: (string | Array<string>), opts: Object): Duration Parameters unit ((string | Array<string>) = ['milliseconds']) the unit or units units (such as 'hours' or 'days') to include in the duration opts (Object = {}) options that affect the creation of the Duration Name Description opts.conversionAccuracy string (default 'casual') the conversion system to use Returns Duration: ▸ until(otherDateTime) Return an Interval spanning between this DateTime and another DateTime until(otherDateTime: DateTime): Interval Parameters otherDateTime (DateTime) the other end point of the Interval Returns Interval: ▸ hasSame(otherDateTime, unit) Return whether this DateTime is in the same unit of time as another DateTime. Higher-order units must also be identical for this function to return true. Note that time zones are ignored in this comparison, which compares the local calendar time. Use DateTime#setZone to convert one of the dates if needed. hasSame(otherDateTime: DateTime, unit: string): boolean Parameters otherDateTime (DateTime) the other DateTime unit (string) the unit of time to check sameness on Returns boolean: Example DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day ▸ equals(other) Equality check Two DateTimes are equal if and only if they represent the same millisecond, have the same zone and location, and are both valid. To compare just the millisecond values, use +dt1 === +dt2. equals(other: DateTime): boolean Parameters other (DateTime) the other DateTime Returns boolean: ▸ toRelative(options) Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your platform supports Intl.RelativeTimeFormat. Rounds down by default. toRelative(options: Object) Parameters options (Object = {}) options that affect the output Name Description options.base DateTime (default DateTime.now()) the DateTime to use as the basis to which this time is compared. Defaults to now. options.style string (default "long") the style of units, must be "long", "short", or "narrow" options.unit (string | Array<string>) use a specific unit or array of units; if omitted, or an array, the method will pick the best unit. Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds" options.round boolean (default true) whether to round the numbers in the output. options.padding number (default 0) padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false} because the decimal output will include the padding. options.locale string override the locale of this DateTime options.numberingSystem string override the numberingSystem of this DateTime. The Intl system may choose not to honor this Example DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day" DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día" DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures" DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago" DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago" DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago" ▸ toRelativeCalendar(options) Returns a string representation of this date relative to today, such as "yesterday" or "next month". Only internationalizes on platforms that supports Intl.RelativeTimeFormat. toRelativeCalendar(options: Object) Parameters options (Object = {}) options that affect the output Name Description options.base DateTime (default DateTime.now()) the DateTime to use as the basis to which this time is compared. Defaults to now. options.locale string override the locale of this DateTime options.unit string use a specific unit; if omitted, the method will pick the unit. Use one of "years", "quarters", "months", "weeks", or "days" options.numberingSystem string override the numberingSystem of this DateTime. The Intl system may choose not to honor this Example DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow" DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana" DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain" DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago" DURATION A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". Conceptually, it's just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. They can be used on their own or in conjunction with other Luxon types; for example, you can use DateTime#plus to add a Duration object to a DateTime, producing another DateTime. Here is a brief overview of commonly used methods and getters in Duration: * Creation To create a Duration, use Duration.fromMillis, Duration.fromObject, or Duration.fromISO. * Unit values See the Duration#years, Duration#months, Duration#weeks, Duration#days, Duration#hours, Duration#minutes, Duration#seconds, Duration#milliseconds accessors. * Configuration See Duration#locale and Duration#numberingSystem accessors. * Transformation To create new Durations out of old ones use Duration#plus, Duration#minus, Duration#normalize, Duration#set, Duration#reconfigure, Duration#shiftTo, and Duration#negate. * Output To convert the Duration into other representations, see Duration#as, Duration#toISO, Duration#toFormat, and Duration#toJSON There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation. new Duration(config: any) Parameters config (any) Static Members ▸ fromMillis(count, opts) Create Duration from a number of milliseconds. fromMillis(count: number, opts: Object): Duration Parameters count (number) of milliseconds opts (Object) options for parsing Name Description opts.locale string (default 'en-US') the locale to use opts.numberingSystem string the numbering system to use opts.conversionAccuracy string (default 'casual') the conversion system to use Returns Duration: ▸ fromObject(obj, opts) Create a Duration from a JavaScript object with keys like 'years' and 'hours'. If this object is empty then a zero milliseconds duration is returned. fromObject(obj: Object, opts: Object): Duration Parameters obj (Object) the object to create the DateTime from Name Description obj.years number obj.quarters number obj.months number obj.weeks number obj.days number obj.hours number obj.minutes number obj.seconds number obj.milliseconds number opts (Object = []) options for creating this Duration Name Description opts.locale string (default 'en-US') the locale to use opts.numberingSystem string the numbering system to use opts.conversionAccuracy string (default 'casual') the preset conversion system to use opts.matrix string (default Object) the custom conversion system to use Returns Duration: ▸ fromDurationLike(durationLike) Create a Duration from DurationLike. fromDurationLike(durationLike: (Object | number | Duration)): Duration Parameters durationLike ((Object | number | Duration)) One of: * object with keys like 'years' and 'hours'. * number representing milliseconds * Duration instance Returns Duration: ▸ fromISO(text, opts) Create a Duration from an ISO 8601 duration string. fromISO(text: string, opts: Object): Duration Parameters text (string) text to parse opts (Object) options for parsing Name Description opts.locale string (default 'en-US') the locale to use opts.numberingSystem string the numbering system to use opts.conversionAccuracy string (default 'casual') the preset conversion system to use opts.matrix string (default Object) the preset conversion system to use Returns Duration: Related https://en.wikipedia.org/wiki/ISO_8601#Durations Example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 } Duration.fromISO('PT23H').toObject() //=> { hours: 23 } Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 } ▸ fromISOTime(text, opts) Create a Duration from an ISO 8601 time string. fromISOTime(text: string, opts: Object): Duration Parameters text (string) text to parse opts (Object) options for parsing Name Description opts.locale string (default 'en-US') the locale to use opts.numberingSystem string the numbering system to use opts.conversionAccuracy string (default 'casual') the preset conversion system to use opts.matrix string (default Object) the conversion system to use Returns Duration: Related https://en.wikipedia.org/wiki/ISO_8601#Times Example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 } Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } ▸ invalid(reason, explanation) Create an invalid Duration. invalid(reason: string, explanation: string): Duration Parameters reason (string) simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent explanation (string = null) longer explanation, may include parameters and other useful debugging information Returns Duration: ▸ isDuration(o) Check if an object is a Duration. Works across context boundaries isDuration(o: object): boolean Parameters o (object) Returns boolean: Instance Members ▸ locale Get the locale of a Duration, such 'en-GB' locale Type: string ▸ numberingSystem Get the numbering system of a Duration, such 'beng'. The numbering system is used when formatting the Duration numberingSystem Type: string ▸ toFormat(fmt, opts) Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens: * S for milliseconds * s for seconds * m for minutes * h for hours * d for days * w for weeks * M for months * y for years Notes: * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits * Tokens can be escaped by wrapping with single quotes. * The duration will be converted to the set of units in the format string using Duration#shiftTo and the Durations's conversion accuracy setting. toFormat(fmt: string, opts: Object): string Parameters fmt (string) the format string opts (Object = {}) options Name Description opts.floor boolean (default true) floor numerical values Returns string: Example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2" Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002" Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000" ▸ toHuman(opts) Returns a string representation of a Duration with all units included. To modify its behavior use the listStyle and any Intl.NumberFormat option, though unitDisplay is especially relevant. toHuman(opts: any) Parameters opts (any = {}) On option object to override the formatting. Accepts the same keys as the options parameter of the native Int.NumberFormat constructor, as well as listStyle . Related https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat Example ```js var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 }) dur.toHuman() //=> '1 day, 5 hours, 6 minutes' dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes' dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min' ``` ▸ toObject() Returns a JavaScript object with this Duration's values. toObject(): Object Returns Object: Example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 } ▸ toISO() Returns an ISO 8601-compliant string representation of this Duration. toISO(): string Returns string: Related https://en.wikipedia.org/wiki/ISO_8601#Durations Example Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S' Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S' Duration.fromObject({ months: 5 }).toISO() //=> 'P5M' Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M' Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S' ▸ toISOTime(opts) Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day. Note that this will return null if the duration is invalid, negative, or equal to or greater than 24 hours. toISOTime(opts: Object): string Parameters opts (Object = {}) options Name Description opts.suppressMilliseconds boolean (default false) exclude milliseconds from the format if they're 0 opts.suppressSeconds boolean (default false) exclude seconds from the format if they're 0 opts.includePrefix boolean (default false) include the T prefix opts.format string (default 'extended') choose between the basic and extended format Returns string: Related https://en.wikipedia.org/wiki/ISO_8601#Times Example Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000' Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00' Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00' Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000' Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000' ▸ toJSON() Returns an ISO 8601 representation of this Duration appropriate for use in JSON. toJSON(): string Returns string: ▸ toString() Returns an ISO 8601 representation of this Duration appropriate for use in debugging. toString(): string Returns string: ▸ toMillis() Returns an milliseconds value of this Duration. toMillis(): number Returns number: ▸ valueOf() Returns an milliseconds value of this Duration. Alias of toMillis valueOf(): number Returns number: ▸ plus(duration) Make this Duration longer by the specified amount. Return a newly-constructed Duration. plus(duration: (Duration | Object | number)): Duration Parameters duration ((Duration | Object | number)) The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() Returns Duration: ▸ minus(duration) Make this Duration shorter by the specified amount. Return a newly-constructed Duration. minus(duration: (Duration | Object | number)): Duration Parameters duration ((Duration | Object | number)) The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() Returns Duration: ▸ mapUnits(fn) Scale this Duration by the specified amount. Return a newly-constructed Duration. mapUnits(fn: function): Duration Parameters fn (function) The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number. Returns Duration: Example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 } Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hours" ? x * 2 : x) //=> { hours: 2, minutes: 30 } ▸ get(unit) Get the value of unit. get(unit: string): number Parameters unit (string) a unit such as 'minute' or 'day' Returns number: Example Duration.fromObject({years: 2, days: 3}).get('years') //=> 2 Duration.fromObject({years: 2, days: 3}).get('months') //=> 0 Duration.fromObject({years: 2, days: 3}).get('days') //=> 3 ▸ set(values) "Set" the values of specified units. Return a newly-constructed Duration. set(values: Object): Duration Parameters values (Object) a mapping of units to numbers Returns Duration: Example dur.set({ years: 2017 }) dur.set({ hours: 8, minutes: 30 }) ▸ reconfigure($0) "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration. reconfigure($0: Object): Duration Parameters $0 (Object = {}) Name Description $0.locale any $0.numberingSystem any $0.conversionAccuracy any $0.matrix any Returns Duration: Example dur.reconfigure({ locale: 'en-GB' }) ▸ as(unit) Return the length of the duration in the specified unit. as(unit: string): number Parameters unit (string) a unit such as 'minutes' or 'days' Returns number: Example Duration.fromObject({years: 1}).as('days') //=> 365 Duration.fromObject({years: 1}).as('months') //=> 12 Duration.fromObject({hours: 60}).as('days') //=> 2.5 ▸ normalize() Reduce this Duration to its canonical representation in its current units. normalize(): Duration Returns Duration: Example Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 } Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 } ▸ rescale() Rescale units to its largest representation rescale(): Duration Returns Duration: Example Duration.fromObject({ milliseconds: 90000 }).rescale().toObject() //=> { minutes: 1, seconds: 30 } ▸ shiftTo(units) Convert this Duration into its representation in a different set of units. shiftTo(units: ...any): Duration Parameters units (...any) Returns Duration: Example Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 } ▸ shiftToAll() Shift this Duration to all available units. Same as shiftTo("years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds") shiftToAll(): Duration Returns Duration: ▸ negate() Return the negative of this Duration. negate(): Duration Returns Duration: Example Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 } ▸ years Get the years. years Type: number ▸ quarters Get the quarters. quarters Type: number ▸ months Get the months. months Type: number ▸ weeks Get the weeks weeks Type: number ▸ days Get the days. days Type: number ▸ hours Get the hours. hours Type: number ▸ minutes Get the minutes. minutes Type: number ▸ seconds Get the seconds. seconds Returns number: ▸ milliseconds Get the milliseconds. milliseconds Returns number: ▸ isValid Returns whether the Duration is invalid. Invalid durations are returned by diff operations on invalid DateTimes or Intervals. isValid Returns boolean: ▸ invalidReason Returns an error code if this Duration became invalid, or null if the Duration is valid invalidReason Returns string: ▸ invalidExplanation Returns an explanation of why this Duration became invalid, or null if the Duration is valid invalidExplanation Type: string ▸ equals(other) Equality check Two Durations are equal iff they have the same units and the same values for each unit. equals(other: Duration): boolean Parameters other (Duration) Returns boolean: INTERVAL An Interval object represents a half-open interval of time, where each endpoint is a DateTime. Conceptually, it's a container for those two endpoints, accompanied by methods for creating, parsing, interrogating, comparing, transforming, and formatting them. Here is a brief overview of the most commonly used methods and getters in Interval: * Creation To create an Interval, use Interval.fromDateTimes, Interval.after, Interval.before, or Interval.fromISO. * Accessors Use Interval#start and Interval#end to get the start and end. * Interrogation To analyze the Interval, use Interval#count, Interval#length, Interval#hasSame, Interval#contains, Interval#isAfter, or Interval#isBefore. * Transformation To create other Intervals out of this one, use Interval#set, Interval#splitAt, Interval#splitBy, Interval#divideEqually, Interval.merge, Interval.xor, Interval#union, Interval#intersection, or Interval#difference. * Comparison To compare this Interval to another one, use Interval#equals, Interval#overlaps, Interval#abutsStart, Interval#abutsEnd, Interval#engulfs * Output To convert the Interval into other representations, see Interval#toString, Interval#toLocaleString, Interval#toISO, Interval#toISODate, Interval#toISOTime, Interval#toFormat, and Interval#toDuration. new Interval(config: any) Parameters config (any) Static Members ▸ invalid(reason, explanation) Create an invalid Interval. invalid(reason: string, explanation: string): Interval Parameters reason (string) simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent explanation (string = null) longer explanation, may include parameters and other useful debugging information Returns Interval: ▸ fromDateTimes(start, end) Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end. fromDateTimes(start: (DateTime | Date | Object), end: (DateTime | Date | Object)): Interval Parameters start ((DateTime | Date | Object)) end ((DateTime | Date | Object)) Returns Interval: ▸ after(start, duration) Create an Interval from a start DateTime and a Duration to extend to. after(start: (DateTime | Date | Object), duration: (Duration | Object | number)): Interval Parameters start ((DateTime | Date | Object)) duration ((Duration | Object | number)) the length of the Interval. Returns Interval: ▸ before(end, duration) Create an Interval from an end DateTime and a Duration to extend backwards to. before(end: (DateTime | Date | Object), duration: (Duration | Object | number)): Interval Parameters end ((DateTime | Date | Object)) duration ((Duration | Object | number)) the length of the Interval. Returns Interval: ▸ fromISO(text, opts?) Create an Interval from an ISO 8601 string. Accepts <start>/<end>, <start>/<duration>, and <duration>/<end> formats. fromISO(text: string, opts: Object?): Interval Parameters text (string) the ISO string to parse opts (Object?) options to pass DateTime#fromISO and optionally Duration#fromISO Returns Interval: Related https://en.wikipedia.org/wiki/ISO_8601#Time_intervals ▸ isInterval(o) Check if an object is an Interval. Works across context boundaries isInterval(o: object): boolean Parameters o (object) Returns boolean: ▸ merge(intervals) Merge an array of Intervals into a equivalent minimal set of Intervals. Combines overlapping and adjacent Intervals. merge(intervals: Array): Array Parameters intervals (Array) Returns Array: ▸ xor(intervals) Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals. xor(intervals: Array): Array Parameters intervals (Array) Returns Array: Instance Members ▸ start Returns the start of the Interval start Type: DateTime ▸ end Returns the end of the Interval end Type: DateTime ▸ isValid Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'. isValid Type: boolean ▸ invalidReason Returns an error code if this Interval is invalid, or null if the Interval is valid invalidReason Type: string ▸ invalidExplanation Returns an explanation of why this Interval became invalid, or null if the Interval is valid invalidExplanation Type: string ▸ length(unit) Returns the length of the Interval in the specified unit. length(unit: string): number Parameters unit (string = "milliseconds") the unit (such as 'hours' or 'days') to return the length in. Returns number: ▸ count(unit) Returns the count of minutes, hours, days, months, or years included in the Interval, even in part. Unlike Interval#length this counts sections of the calendar, not periods of time, e.g. specifying 'day' asks 'what dates are included in this interval?', not 'how many days long is this interval?' count(unit: string): number Parameters unit (string = 'milliseconds') the unit of time to count. Returns number: ▸ hasSame(unit) Returns whether this Interval's start and end are both in the same unit of time hasSame(unit: string): boolean Parameters unit (string) the unit of time to check sameness on Returns boolean: ▸ isEmpty() Return whether this Interval has the same start and end DateTimes. isEmpty(): boolean Returns boolean: ▸ isAfter(dateTime) Return whether this Interval's start is after the specified DateTime. isAfter(dateTime: DateTime): boolean Parameters dateTime (DateTime) Returns boolean: ▸ isBefore(dateTime) Return whether this Interval's end is before the specified DateTime. isBefore(dateTime: DateTime): boolean Parameters dateTime (DateTime) Returns boolean: ▸ contains(dateTime) Return whether this Interval contains the specified DateTime. contains(dateTime: DateTime): boolean Parameters dateTime (DateTime) Returns boolean: ▸ set(values) "Sets" the start and/or end dates. Returns a newly-constructed Interval. set(values: Object): Interval Parameters values (Object = {}) the values to set Name Description values.start DateTime the starting DateTime values.end DateTime the ending DateTime Returns Interval: ▸ splitAt(dateTimes) Split this Interval at each of the specified DateTimes splitAt(dateTimes: ...DateTime): Array Parameters dateTimes (...DateTime) the unit of time to count. Returns Array: ▸ splitBy(duration) Split this Interval into smaller Intervals, each of the specified length. Left over time is grouped into a smaller interval splitBy(duration: (Duration | Object | number)): Array Parameters duration ((Duration | Object | number)) The length of each resulting interval. Returns Array: ▸ divideEqually(numberOfParts) Split this Interval into the specified number of smaller intervals. divideEqually(numberOfParts: number): Array Parameters numberOfParts (number) The number of Intervals to divide the Interval into. Returns Array: ▸ overlaps(other) Return whether this Interval overlaps with the specified Interval overlaps(other: Interval): boolean Parameters other (Interval) Returns boolean: ▸ abutsStart(other) Return whether this Interval's end is adjacent to the specified Interval's start. abutsStart(other: Interval): boolean Parameters other (Interval) Returns boolean: ▸ abutsEnd(other) Return whether this Interval's start is adjacent to the specified Interval's end. abutsEnd(other: Interval): boolean Parameters other (Interval) Returns boolean: ▸ engulfs(other) Return whether this Interval engulfs the start and end of the specified Interval. engulfs(other: Interval): boolean Parameters other (Interval) Returns boolean: ▸ equals(other) Return whether this Interval has the same start and end as the specified Interval. equals(other: Interval): boolean Parameters other (Interval) Returns boolean: ▸ intersection(other) Return an Interval representing the intersection of this Interval and the specified Interval. Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals. Returns null if the intersection is empty, meaning, the intervals don't intersect. intersection(other: Interval): Interval Parameters other (Interval) Returns Interval: ▸ union(other) Return an Interval representing the union of this Interval and the specified Interval. Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals. union(other: Interval): Interval Parameters other (Interval) Returns Interval: ▸ difference(intervals) Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals. difference(intervals: ...Interval): Array Parameters intervals (...Interval) Returns Array: ▸ toString() Returns a string representation of this Interval appropriate for debugging. toString(): string Returns string: ▸ toLocaleString(formatOpts, opts) Returns a localized string representing this Interval. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, such as DateTime.DATE_FULL or DateTime.TIME_SIMPLE. The exact behavior of this method is browser-specific, but in general it will return an appropriate representation of the Interval in the assigned locale. Defaults to the system's locale if no locale has been specified. toLocaleString(formatOpts: Object, opts: Object): string Parameters formatOpts (Object = DateTime.DATE_SHORT) Either a DateTime preset or Intl.DateTimeFormat constructor options. opts (Object = {}) Options to override the configuration of the start DateTime. Returns string: Related https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat Example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(); //=> 11/7/2022 – 11/8/2022 Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL); //=> November 7 – 8, 2022 Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' }); //=> 7–8 novembre 2022 Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString(DateTime.TIME_SIMPLE); //=> 6:00 – 8:00 PM Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> Mon, Nov 07, 6:00 – 8:00 p ▸ toISO(opts) Returns an ISO 8601-compliant string representation of this Interval. toISO(opts: Object): string Parameters opts (Object) The same options as DateTime#toISO Returns string: Related https://en.wikipedia.org/wiki/ISO_8601#Time_intervals ▸ toISODate() Returns an ISO 8601-compliant string representation of date of this Interval. The time components are ignored. toISODate(): string Returns string: Related https://en.wikipedia.org/wiki/ISO_8601#Time_intervals ▸ toISOTime(opts) Returns an ISO 8601-compliant string representation of time of this Interval. The date components are ignored. toISOTime(opts: Object): string Parameters opts (Object) The same options as DateTime#toISO Returns string: Related https://en.wikipedia.org/wiki/ISO_8601#Time_intervals ▸ toFormat(dateFormat, opts) Returns a string representation of this Interval formatted according to the specified format string. You may not want this. See Interval#toLocaleString for a more flexible formatting tool. toFormat(dateFormat: string, opts: Object): string Parameters dateFormat (string) The format string. This string formats the start and end time. See DateTime#toFormat for details. opts (Object = {}) Options. Name Description opts.separator string (default ' – ') A separator to place between the start and end representations. Returns string: ▸ toDuration(unit, opts) Return a Duration representing the time spanned by this interval. toDuration(unit: (string | Array<string>), opts: Object): Duration Parameters unit ((string | Array<string>) = ['milliseconds']) the unit or units (such as 'hours' or 'days') to include in the duration. opts (Object) options that affect the creation of the Duration Name Description opts.conversionAccuracy string (default 'casual') the conversion system to use Returns Duration: Example Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 } Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 } Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 } Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 } Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 } ▸ mapEndpoints(mapFn) Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes mapEndpoints(mapFn: function): Interval Parameters mapFn (function) Returns Interval: Example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC()) Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 })) INFO The Info class contains static methods for retrieving general time and date related data. For example, it has methods for finding out if a time zone has a DST, for listing the months in any supported locale, and for discovering which of Luxon features are available in the current environment. new Info() Static Members ▸ hasDST(zone) Return whether the specified zone contains a DST. hasDST(zone: (string | Zone)): boolean Parameters zone ((string | Zone) = 'local') Zone to check. Defaults to the environment's local zone. Returns boolean: ▸ isValidIANAZone(zone) Return whether the specified zone is a valid IANA specifier. isValidIANAZone(zone: string): boolean Parameters zone (string) Zone to check Returns boolean: ▸ normalizeZone(input?) Converts the input into a Zone instance. * If input is already a Zone instance, it is returned unchanged. * If input is a string containing a valid time zone name, a Zone instance with that name is returned. * If input is a string that doesn't refer to a known time zone, a Zone instance with Zone#isValid == false is returned. * If `input is a number, a Zone instance with the specified fixed offset in minutes is returned. * If input is null or undefined, the default zone is returned. normalizeZone(input: (string | Zone | number)?): Zone Parameters input ((string | Zone | number)?) the value to be converted Returns Zone: ▸ months(length, opts) Return an array of standalone month names. months(length: string, opts: Object): Array Parameters length (string = 'long') the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long" opts (Object = {}) options Name Description opts.locale string? (default null) the locale code opts.numberingSystem string (default null) the numbering system opts.locObj string (default null) an existing locale object to use opts.outputCalendar string (default 'gregory') the calendar Returns Array: Related https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat Example Info.months()[0] //=> 'January' Info.months('short')[0] //=> 'Jan' Info.months('numeric')[0] //=> '1' Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.' Info.months('numeric', { locale: 'ar' })[0] //=> '١' Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I' ▸ monthsFormat(length, opts) Return an array of format month names. Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that changes the string. See Info#months monthsFormat(length: string, opts: Object): Array Parameters length (string = 'long') the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long" opts (Object = {}) options Name Description opts.locale string? (default null) the locale code opts.numberingSystem string (default null) the numbering system opts.locObj string (default null) an existing locale object to use opts.outputCalendar string (default 'gregory') the calendar Returns Array: ▸ weekdays(length, opts) Return an array of standalone week names. weekdays(length: string, opts: Object): Array Parameters length (string = 'long') the length of the weekday representation, such as "narrow", "short", "long". opts (Object = {}) options Name Description opts.locale string? (default null) the locale code opts.numberingSystem string (default null) the numbering system opts.locObj string (default null) an existing locale object to use Returns Array: Related https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat Example Info.weekdays()[0] //=> 'Monday' Info.weekdays('short')[0] //=> 'Mon' Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.' Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين' ▸ weekdaysFormat(length, opts) Return an array of format week names. Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that changes the string. See Info#weekdays weekdaysFormat(length: string, opts: Object): Array Parameters length (string = 'long') the length of the month representation, such as "narrow", "short", "long". opts (Object = {}) options Name Description opts.locale string (default null) the locale code opts.numberingSystem string (default null) the numbering system opts.locObj string (default null) an existing locale object to use Returns Array: ▸ meridiems(opts) Return an array of meridiems. meridiems(opts: Object): Array Parameters opts (Object = {}) options Name Description opts.locale string? (default null) the locale code Returns Array: Example Info.meridiems() //=> [ 'AM', 'PM' ] Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ] ▸ eras(length, opts) Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian. eras(length: string, opts: Object): Array Parameters length (string = 'short') the length of the era representation, such as "short" or "long". opts (Object = {}) options Name Description opts.locale string? (default null) the locale code Returns Array: Example Info.eras() //=> [ 'BC', 'AD' ] Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ] Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ] ▸ features() Return the set of available features in this environment. Some features of Luxon are not available in all environments. For example, on older browsers, relative time formatting support is not available. Use this function to figure out if that's the case. Keys: * relative: whether this environment supports relative time formatting features(): Object Returns Object: Example Info.features() //=> { relative: false } ZONE Zone Instance Members ▸ type The type of zone type Type: string ▸ name The name of this zone. name Type: string ▸ isUniversal Returns whether the offset is known to be fixed for the whole year. isUniversal Type: boolean ▸ offsetName(ts, opts) Returns the offset's common name (such as EST) at the specified timestamp offsetName(ts: number, opts: Object): string Parameters ts (number) Epoch milliseconds for which to get the name opts (Object) Options to affect the format Name Description opts.format string What style of offset to return. Accepts 'long' or 'short'. opts.locale string What locale to return the offset name in. Returns string: ▸ formatOffset(ts, format) Returns the offset's value as a string formatOffset(ts: number, format: string): string Parameters ts (number) Epoch milliseconds for which to get the offset format (string) What style of offset to return. Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively Returns string: ▸ offset(ts) Return the offset in minutes for this zone at the specified timestamp. offset(ts: number): number Parameters ts (number) Epoch milliseconds for which to compute the offset Returns number: ▸ equals(otherZone) Return whether this Zone is equal to another zone equals(otherZone: Zone): boolean Parameters otherZone (Zone) the zone to compare Returns boolean: ▸ isValid Return whether this Zone is valid. isValid Type: boolean FIXEDOFFSETZONE A zone with a fixed offset (meaning no DST) new FixedOffsetZone(offset: any) Extends Zone Parameters offset (any) Static Members ▸ utcInstance Get a singleton instance of UTC utcInstance Returns FixedOffsetZone: ▸ instance(offset) Get an instance with a specified offset instance(offset: number): FixedOffsetZone Parameters offset (number) The offset in minutes Returns FixedOffsetZone: ▸ parseSpecifier(s) Get an instance of FixedOffsetZone from a UTC offset string, like "UTC+6" parseSpecifier(s: string): FixedOffsetZone Parameters s (string) The offset string to parse Returns FixedOffsetZone: Example FixedOffsetZone.parseSpecifier("UTC+6") FixedOffsetZone.parseSpecifier("UTC+06") FixedOffsetZone.parseSpecifier("UTC-6:00") Instance Members ▸ type type ▸ name name ▸ offsetName() offsetName() ▸ formatOffset(ts, format) formatOffset(ts: any, format: any) Parameters ts (any) format (any) ▸ isUniversal isUniversal ▸ offset() offset() ▸ equals(otherZone) equals(otherZone: any) Parameters otherZone (any) ▸ isValid isValid IANAZONE A zone identified by an IANA identifier, like America/New_York new IANAZone(name: any) Extends Zone Parameters name (any) Static Members ▸ create(name) create(name: string): IANAZone Parameters name (string) Zone name Returns IANAZone: ▸ resetCache() Reset local caches. Should only be necessary in testing scenarios. resetCache(): void Returns void: ▸ isValidSpecifier(s) Returns whether the provided string is a valid specifier. This only checks the string's format, not that the specifier identifies a known zone; see isValidZone for that. isValidSpecifier(s: string): boolean Deprecated: This method returns false for some valid IANA names. Use isValidZone instead. Parameters s (string) The string to check validity on Returns boolean: Example IANAZone.isValidSpecifier("America/New_York") //=> true IANAZone.isValidSpecifier("Sport~~blorp") //=> false ▸ isValidZone(zone) Returns whether the provided string identifies a real zone isValidZone(zone: string): boolean Parameters zone (string) The string to check Returns boolean: Example IANAZone.isValidZone("America/New_York") //=> true IANAZone.isValidZone("Fantasia/Castle") //=> false IANAZone.isValidZone("Sport~~blorp") //=> false Instance Members ▸ type type ▸ name name ▸ isUniversal isUniversal ▸ offsetName(ts, $1) offsetName(ts: any, $1: Object) Parameters ts (any) $1 (Object) Name Description $1.format any $1.locale any ▸ formatOffset(ts, format) formatOffset(ts: any, format: any) Parameters ts (any) format (any) ▸ offset(ts) offset(ts: any) Parameters ts (any) ▸ equals(otherZone) equals(otherZone: any) Parameters otherZone (any) ▸ isValid isValid INVALIDZONE A zone that failed to parse. You should never need to instantiate this. new InvalidZone(zoneName: any) Extends Zone Parameters zoneName (any) Instance Members ▸ type type ▸ name name ▸ isUniversal isUniversal ▸ offsetName() offsetName() ▸ formatOffset() formatOffset() ▸ offset() offset() ▸ equals() equals() ▸ isValid isValid SYSTEMZONE Represents the local zone for this JavaScript environment. new SystemZone() Extends Zone Static Members ▸ instance Get a singleton instance of the local zone instance Returns SystemZone: Instance Members ▸ type type ▸ name name ▸ isUniversal isUniversal ▸ offsetName(ts, $1) offsetName(ts: any, $1: Object) Parameters ts (any) $1 (Object) Name Description $1.format any $1.locale any ▸ formatOffset(ts, format) formatOffset(ts: any, format: any) Parameters ts (any) format (any) ▸ offset(ts) offset(ts: any) Parameters ts (any) ▸ equals(otherZone) equals(otherZone: any) Parameters otherZone (any) ▸ isValid isValid SETTINGS Settings contains static getters and setters that control Luxon's overall behavior. Luxon is a simple library with few options, but the ones it does have live here. new Settings() Static Members ▸ now Get the callback for returning the current timestamp. now Type: function ▸ now Set the callback for returning the current timestamp. The function should return a number, which will be interpreted as an Epoch millisecond count now Type: function Parameters n (any) Example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time ▸ defaultZone Set the default time zone to create DateTimes in. Does not affect existing instances. Use the value "system" to reset this value to the system's time zone. defaultZone Type: string Parameters zone (any) ▸ defaultZone Get the default time zone object currently used to create DateTimes. Does not affect existing instances. The default value is the system's time zone (the one set on the machine that runs this code). defaultZone Type: Zone ▸ defaultLocale Get the default locale to create DateTimes with. Does not affect existing instances. defaultLocale Type: string ▸ defaultLocale Set the default locale to create DateTimes with. Does not affect existing instances. defaultLocale Type: string Parameters locale (any) ▸ defaultNumberingSystem Get the default numbering system to create DateTimes with. Does not affect existing instances. defaultNumberingSystem Type: string ▸ defaultNumberingSystem Set the default numbering system to create DateTimes with. Does not affect existing instances. defaultNumberingSystem Type: string Parameters numberingSystem (any) ▸ defaultOutputCalendar Get the default output calendar to create DateTimes with. Does not affect existing instances. defaultOutputCalendar Type: string ▸ defaultOutputCalendar Set the default output calendar to create DateTimes with. Does not affect existing instances. defaultOutputCalendar Type: string Parameters outputCalendar (any) ▸ twoDigitCutoffYear Get the cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century. twoDigitCutoffYear Type: number ▸ twoDigitCutoffYear Set the cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century. twoDigitCutoffYear Type: number Parameters cutoffYear (any) Example Settings.twoDigitCutoffYear = 0 // cut-off year is 0, so all 'yy' are interpretted as current century Settings.twoDigitCutoffYear = 50 // '49' -> 1949; '50' -> 2050 Settings.twoDigitCutoffYear = 1950 // interpretted as 50 Settings.twoDigitCutoffYear = 2050 // ALSO interpretted as 50 ▸ throwOnInvalid Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals throwOnInvalid Type: boolean ▸ throwOnInvalid Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals throwOnInvalid Type: boolean Parameters t (any) ▸ resetCaches() Reset Luxon's global caches. Should only be necessary in testing scenarios. resetCaches(): void Returns void: