Creates a DateTime from various input. A single argument may be date input or an options object. Two arguments represents input and an options object. If no arguments are passed the DateTime will be the current date.
If the input is a string that specifies a timezone or offset it will be used
as is. Otherwise if the timeZone option is specified or a global timezone
is set it will be parsed in that timezone. If no timezone can be derived the
system offset will be used instead.
StaticDATE_StaticDATE_StaticDATE_StaticDATE_StaticDATETIME_StaticDATETIME_StaticDATETIME_StaticDATETIME_StaticMONTH_StaticMONTH_StaticoptionsStaticTIME_StaticTIME_StaticTIME_StaticTIME_StaticTIME_Advances the DateTime. When the first argument is a number it must be followed by a unit advancing by that many units. If the first argument is an object it will advance the date by multiple units.
Optionalunit: TimeUnitReturns a clone of the DateTime.
Returns the number of days in the month.
Advances the DateTime to the end of the specified unit.
Advances the DateTime to the end of the calendar month. This may push the date into the next month.
Advances the DateTime to the end of the day.
Advances the DateTime to the end of the month.
Advances the DateTime to the end of the week.
Advances the DateTime to the end of the year.
Formats the DateTime using various formats accessible as static members of the DateTime class.
Gets the date of the DateTime.
Gets the day of week of the DateTime from 0 to 6.
Gets the year of the DateTime.
Gets the hours of the DateTime.
Gets the milliseconds of the DateTime.
Gets the minutes of the DateTime.
Gets the month of the DateTime. Note that months are zero based so January is 0.
Gets the seconds of the DateTime.
Returns the unix timestamp of the DateTime.
Alias for getTimeZone.
Returns the IANA timezone.
Alias for getTimeZoneOffset.
Gets the timezone offset of the DateTime in minutes. This may be the offset of the local or global timezone if one is set, otherwise will be the system offset.
Gets the date in UTC.
Gets the day in UTC.
Gets the year in UTC.
Gets the hours in UTC.
Gets the milliseconds in UTC.
Gets the minutes in UTC.
Gets the month in UTC.
Gets the seconds in UTC.
Alias for getFullYear.
Returns true if the DateTime is equivalent to the passed value..
Returns true if the DateTime is invalid.
Returns true if the DateTime is valid.
Formats the DateTime in a relative format. Allowed options are:
now - Offset to format relative to. Defaults to the current time.min - When set will return undefined if the DateTime is before this date.max - When set will return undefined if the DateTime is after this date.numeric - Passed to Intl.RelativeTimeFormat. Defaults to auto but may
also be always.Optionaloptions: { max?: DateLike; min?: DateLike; now?: DateLike; numeric?: string }Resets the time to 00:00:00.000. Equivalent to startOfDay.
Rewinds the DateTime. When the first argument is a number it must be followed by a unit rewinding by that many units. If the first argument is an object it will rewind the date by multiple units.
Optionalunit: TimeUnitSets components of the DateTime by name.
Optionalday?: numberThe day of the month to set.
Optionalhour?: numberThe hours to set.
Optionalhours?: numberThe hours to set.
Optionalmillisecond?: numberThe milliseconds to set.
Optionalmilliseconds?: numberThe milliseconds to set.
Optionalminute?: numberThe minutes to set.
Optionalminutes?: numberThe minutes to set.
Optionalmonth?: numberThe month to set.
Optionalsecond?: numberThe seconds to set.
Optionalseconds?: numberThe seconds to set.
Optionalyear?: numberThe year to set.
Sets the arguments for the UTC time.
A list of arguments representing the date components.
Sets the month of the DateTime. Note that months are zero based so January is 0.
Rewinds the DateTime to the start of the specified unit.
Rewinds the DateTime to the start of the calendar month. This may push the date into the previous month.
Rewinds the DateTime to the start of the day.
Rewinds the DateTime to the start of the month.
Rewinds the DateTime to the start of the week.
Rewinds the DateTime to the start of the year.
Returns the ISO-8601 representation of the date component of the DateTime in UTC.
Returns the ISO-8601 representation of the DateTime.
Returns the ISO-8601 representation of the time component of the DateTime in UTC.
Equivalent to toISOString.
Returns a default formatted string that represents the DateTime.
Returns the numeric value of the DateTime instance.
StaticclampClamps the value passed to the minimum and maximum.
DateTime
StaticgetGets the meridiem tokens (am/pm) a given locale. Options are:
locale - If not passed will use the global locale or fall
back to the system locale.lower - Return the tokens in lower case.style - When "short" will return a/p for am/pm tokens only.StaticgetGets the months of the year for a given locale. Options are:
locale - If not passed will use the global locale or fall
back to the system locale.style - Will be passed as month to Intl.DateTimeFormat. Default long.StaticgetGets the weekday names for a given locale. Options are:
locale - If not passed will use the global locale or fall
back to the system locale.start - An explicit start day of the week, 0 for sunday, 6 for Saturday.
Will fall back to the locale defined first day.style - Will be passed as weekday to Intl.DateTimeFormat. Default long.StaticmaxReturns the maximum value passed in as a DateTime.
DateTime
StaticminReturns the minimum value passed in as a DateTime.
DateTime
StaticsetSets the global locale.
StaticsetSets global options.
StaticsetSets the global timezone.
A timezone and locale aware DateTime. This class assumes support for:
Intl.DateTimeFormatIntl.RelativeTimeFormat