Static
Readonly
DATETIME_toLocaleString format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
Static
Readonly
DATETIME_toLocaleString format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
Static
Readonly
DATE_toLocaleString format like 'October 14, 1983'
Static
Readonly
DATE_toLocaleString format like 'Tuesday, October 14, 1983'
Static
Readonly
DATE_toLocaleString format like 'Oct 14, 1983'
Static
Readonly
DATE_toLocaleString format like 'Fri, Oct 14, 1983'
Static
Readonly
DATE_toLocaleString format like 10/14/1983
Static
Readonly
TIME_toLocaleString format like '09:30', always 24-hour.
Static
Readonly
TIME_toLocaleString format like '09:30:23 Eastern Daylight Time', always 24-hour.
Static
Readonly
TIME_toLocaleString format like '09:30:23', always 24-hour.
Static
Readonly
TIME_toLocaleString format like '09:30:23 EDT', always 24-hour.
Static
Readonly
TIME_toLocaleString format like '09:30 AM'. Only 12-hour if the locale is.
Static
Readonly
TIME_toLocaleString format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
Static
Readonly
TIME_toLocaleString format like '09:30:23 AM'. Only 12-hour if the locale is.
Static
Readonly
TIME_toLocaleString format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
Get the day of the month (1-30ish).
DateTime.local(2017, 5, 25).day //=> 25
Returns the number of days in this DateTime's month
DateTime.local(2016, 2).daysInMonth //=> 29
DateTime.local(2016, 3).daysInMonth //=> 31
Returns the number of days in this DateTime's year
DateTime.local(2016).daysInYear //=> 366
DateTime.local(2013).daysInYear //=> 365
Get the hour of the day (0-23).
DateTime.local(2017, 5, 25, 9).hour //=> 9
Returns an explanation of why this Duration became invalid, or null if the Duration is valid
Returns an error code if this Duration became invalid, or null if the Duration is valid
Get whether the DateTime is in a DST.
Returns true if this DateTime is in a leap year, false otherwise
DateTime.local(2016).isInLeapYear //=> true
DateTime.local(2013).isInLeapYear //=> false
Get whether this zone's offset ever changes, as in a DST.
Returns whether the DateTime is valid. Invalid DateTimes occur when:
Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime
Get the millisecond of the second (0-999).
DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654
Get the minute of the hour (0-59).
DateTime.local(2017, 5, 25, 9, 30).minute //=> 30
Get the month (1-12).
DateTime.local(2017, 5, 25).month //=> 5
Get the human readable long month name, such as 'October'. Defaults to the system's locale if no locale has been specified
DateTime.local(2017, 10, 30).monthLong //=> October
Get the human readable short month name, such as 'Oct'. Defaults to the system's locale if no locale has been specified
DateTime.local(2017, 10, 30).monthShort //=> Oct
Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime
Get the UTC offset of this DateTime in minutes
DateTime.now().offset //=> -240
DateTime.utc().offset //=> 0
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
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
Get the ordinal (meaning the day of the year)
DateTime.local(2017, 5, 25).ordinal //=> 145
Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime
Get the quarter
DateTime.local(2017, 5, 25).quarter //=> 2
Get the second of the minute (0-59).
DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52
Get the timestamp.
DateTime.local(1970, 1, 1, 0, 0, 0, 654).ts //=> 654
Get the week number of the week year (1-52ish).
https://en.wikipedia.org/wiki/ISO_week_date
DateTime.local(2017, 5, 25).weekNumber //=> 21
Get the week year
https://en.wikipedia.org/wiki/ISO_week_date
DateTime.local(2014, 12, 31).weekYear //=> 2015
Get the day of the week. 1 is Monday and 7 is Sunday
https://en.wikipedia.org/wiki/ISO_week_date
DateTime.local(2014, 11, 31).weekday //=> 4
Get the human readable long weekday, such as 'Monday'. Defaults to the system's locale if no locale has been specified
DateTime.local(2017, 10, 30).weekdayLong //=> Monday
Get the human readable short weekday, such as 'Mon'. Defaults to the system's locale if no locale has been specified
DateTime.local(2017, 10, 30).weekdayShort //=> Mon
Returns the number of weeks in this DateTime's year
https://en.wikipedia.org/wiki/ISO_week_date
DateTime.local(2004).weeksInWeekYear //=> 53
DateTime.local(2013).weeksInWeekYear //=> 52
Get the year
DateTime.local(2017, 5, 25).year //=> 2017
Get the name of the time zone.
Returns the difference between two DateTimes as a Duration.
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 }
the DateTime to compare this one to
Optional
unit: keyof DurationObject | (keyof DurationObject)[] = "milliseconds"the unit or array of units (such as 'hours' or 'days') to include in the duration.
options that affect the creation of the Duration
Returns the difference between this DateTime and right now. See diff
Optional
unit: keyof DurationObject | (keyof DurationObject)[] = "milliseconds"the unit or units units (such as 'hours' or 'days') to include in the duration
options that affect the creation of the Duration
"Set" this DateTime to the end (meaning the last millisecond) of a unit of time
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, 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'
The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
Get the value of unit.
DateTime.local(2017, 7, 4).get('month'); //=> 7
DateTime.local(2017, 7, 4).get('day'); //=> 4
a unit such as 'minute' or 'day'
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 setZone to convert one of the dates if needed.
DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day
the other DateTime
the unit of time to check sameness on
Subtract a period of time to this DateTime and return the resulting DateTime See plus
The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
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.
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
The amount to add. Either a Luxon Duration or the object argument to Duration.fromObject()
"Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' })
Optional
options: LocaleOptionsthe options to set
Returns the resolved Intl options for this DateTime. This is useful in understanding the behavior of formatting methods
the same options as toLocaleString
"Set" the values of specified units. Returns a newly-constructed DateTime. You can only set units with this method; for "setting" metadata, see reconfigure and setZone.
dt.set({ year: 2017 })
dt.set({ hour: 8, minute: 30 })
dt.set({ weekday: 5 })
dt.set({ year: 2005, ordinal: 234 })
a mapping of units to numbers
"Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime.
By default, the setter keeps the underlying instant the same (as in, the same timestamp), but the new instance will report different local time and consider DSTs when making computations, as with plus. You may wish to use DateTime.toSystemZone and toUTC which provide simple convenience wrappers for commonly used zones.
Optional
zone: ZoneLikea 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 'default', 'system' or 'utc'. You may also supply an instance of a Zone class.
options
"Set" this DateTime to the beginning of a unit of time.
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, 5, 30).startOf('week').toISOTime(); //=> '2014-03-03', weeks always start on a Monday
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'
The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
Returns a string representation of this DateTime formatted according to the specified format string. You may not want this. See 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.
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'
the format string
opts to override the configuration options on this DateTime
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.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
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'
Returns an ISO 8601-compliant string representation of this DateTime
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'
options
Returns an ISO 8601-compliant string representation of this DateTime's date component
DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'
options
Optional
format?: ToISOFormatchoose between the basic and extended format
Returns an ISO 8601-compliant string representation of this DateTime's time component
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'
options
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
DateTime.now().toLocaleParts(); //=> [
//=> { type: 'day', value: '25' },
//=> { type: 'literal', value: '/' },
//=> { type: 'month', value: '05' },
//=> { type: 'literal', value: '/' },
//=> { type: 'year', value: '1982' }
//=> ]
{Object} - Intl.DateTimeFormat constructor options, same as toLocaleString
.
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
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
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'
{Object} - Intl.DateTimeFormat constructor options and configuration options
opts to override the configuration options on this DateTime
Returns a JavaScript object with this DateTime's year, month, day, and so on.
DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 }
options for generating the object
include configuration attributes in the output
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.
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"
options that affect the output
Returns a string representation of this date relative to today, such as "yesterday" or "next month". Only internationalizes on platforms that supports Intl.RelativeTimeFormat.
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"
options that affect the output
Returns a string representation of this DateTime appropriate for use in SQL DateTime
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'
options
Returns a string representation of this DateTime appropriate for use in SQL Time
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'
options
"Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.
Equivalent to setZone('utc')
Optional
offset: number = 0optionally, an offset from UTC in minutes
Optional
opts: SetZoneOptions = {}options to pass to setZone()
Returns the epoch milliseconds of this DateTime. Alias of toMillis
Static
expandProduce the fully expanded format token for the locale Does NOT quote characters, so quoted tokens will not round trip correctly
Static
fromCreate 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.
https://moment.github.io/luxon/docs/manual/parsing.html#table-of-tokens
the string to parse
the format the string is expected to be in (see the link below for the formats)
options to affect the creation
Static
fromExplain how a string would be parsed by fromFormat()
the string to parse
the format the string is expected to be in (see description)
options taken by fromFormat()
Static
fromHTTPCreate a DateTime from an HTTP header date
https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
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')
the HTTP header date
options to affect the creation
Static
fromISOCreate a DateTime from an ISO 8601 string
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')
the ISO string
options to affect the creation
Static
fromJSDateCreate a DateTime from a Javascript Date object. Uses the default zone.
a Javascript Date object
configuration options for the DateTime
Static
fromCreate a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
a number of milliseconds since 1970 UTC
configuration options for the DateTime
Static
fromCreate a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults.
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'
the object to create the DateTime from
options for creating this DateTime
Static
fromRFC2822Create a DateTime from an RFC 2822 string
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')
the RFC 2822 string
options to affect the creation
Static
fromSQLCreate 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
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')
the string to parse
options to affect the creation
Static
fromCreate a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
a number of seconds since 1970 UTC
configuration options for the DateTime
Static
fromuse fromFormat instead
Static
fromuse fromFormatExplain instead
Static
invalidCreate an invalid DateTime.
simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent
Optional
explanation: stringlonger explanation, may include parameters and other useful debugging information
Static
isStatic
localCreate a local DateTime
[year] - The calendar year. If omitted (as in, call local()
with no arguments), the current time will be used
{number} [month=1] - The month, 1-indexed
{number} [day=1] - The day of the month, 1-indexed
{number} [hour=0] - The hour of the day, in 24-hour time
{number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
{number} [second=0] - The second of the minute, meaning a number between 0 and 59
{number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
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, 10) //~> 2017-03-12T05:45:10
DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
Rest
...args: [DateTimeOptions] | number[] | (number | DateTimeOptions)[]The date values (year, month, etc.) and/or the configuration options for the DateTime
Static
maxReturn the max of several date times
the max DateTime, or undefined if called with no arguments
Rest
...dateTimes: []the DateTimes from which to choose the maximum
Rest
...dateTimes: DateTime[]Static
minReturn the min of several date times
the min DateTime, or undefined if called with no arguments
Rest
...dateTimes: []the DateTimes from which to choose the minimum
Rest
...dateTimes: DateTime[]Static
nowStatic
parseProduce the format string for a set of options
Static
utcCreate a DateTime in UTC
[year] - The calendar year. If omitted (as in, call utc()
with no arguments), the current time will be used
{number} [month=1] - The month, 1-indexed
{number} [day=1] - The day of the month
{number} [hour=0] - The hour of the day, in 24-hour time
{number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
{number} [second=0] - The second of the minute, meaning a number between 0 and 59
{number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
{Object} options - configuration options for the DateTime
{string} [options.locale] - a locale to set on the resulting DateTime instance
{string} [options.outputCalendar] - the output calendar to set on the resulting DateTime instance
{string} [options.numberingSystem] - the numbering system to set on the resulting DateTime instance
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
Rest
...args: [DateTimeOptions] | number[] | (number | DateTimeOptions)[]The date values (year, month, etc.) and/or the configuration options for the DateTime
Generated using TypeDoc
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:
locale
,numberingSystem
, andoutputCalendar
.Here is a brief overview of the most commonly used functionality it provides:
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.