Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as mod from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";

§Variables

formatters
lightFormatters
longFormatters
parsers

§Functions

add
addBusinessDays
addDays
addHours
addISOWeekYears
addMilliseconds
addMinutes
addMonths
addQuarters
addSeconds
addWeeks
addYears
areIntervalsOverlapping
clamp
closestIndexTo
closestTo
compareAsc
compareDesc
constructFrom
constructNow
daysToWeeks
differenceInBusinessDays
differenceInCalendarDays
differenceInCalendarISOWeeks
differenceInCalendarISOWeekYears
differenceInCalendarMonths
differenceInCalendarQuarters
differenceInCalendarWeeks
differenceInCalendarYears
differenceInDays
differenceInHours
differenceInISOWeekYears
differenceInMilliseconds
differenceInMinutes
differenceInMonths
differenceInQuarters
differenceInSeconds
differenceInWeeks
differenceInYears
eachDayOfInterval
eachHourOfInterval
eachMinuteOfInterval
eachMonthOfInterval
eachQuarterOfInterval
eachWeekendOfInterval
eachWeekendOfMonth
eachWeekendOfYear
eachWeekOfInterval
eachYearOfInterval
endOfDay
endOfDecade
endOfHour
endOfISOWeek
endOfISOWeekYear
endOfMinute
endOfMonth
endOfQuarter
endOfSecond
endOfToday
endOfTomorrow
endOfWeek
endOfYear
endOfYesterday
format
formatDate
formatDistance
formatDistanceStrict
formatDistanceToNow
formatDistanceToNowStrict
formatDuration
formatISO
formatISO9075
formatISODuration
formatRelative
formatRFC3339
formatRFC7231
fromUnixTime
getDate
getDay
getDayOfYear
getDaysInMonth
getDaysInYear
getDecade
getDefaultOptions
getHours
getISODay
getISOWeek
getISOWeeksInYear
getISOWeekYear
getMilliseconds
getMinutes
getMonth
getOverlappingDaysInIntervals
getQuarter
getSeconds
getTime
getUnixTime
getWeek
getWeekOfMonth
getWeeksInMonth
getWeekYear
getYear
hoursToMilliseconds
hoursToMinutes
hoursToSeconds
interval
intervalToDuration
intlFormat
intlFormatDistance
isAfter
isBefore
isDate
isEqual
isExists
isFirstDayOfMonth
isFriday
isFuture
isLastDayOfMonth
isLeapYear
isMatch
isMonday
isPast
isSameDay
isSameHour
isSameISOWeek
isSameISOWeekYear
isSameMinute
isSameMonth
isSameQuarter
isSameSecond
isSameWeek
isSameYear
isSaturday
isSunday
isThisHour
isThisISOWeek
isThisMinute
isThisMonth
isThisQuarter
isThisSecond
isThisWeek
isThisYear
isThursday
isToday
isTomorrow
isTuesday
isValid
isWednesday
isWeekend
isWithinInterval
isYesterday
lastDayOfDecade
lastDayOfISOWeek
lastDayOfISOWeekYear
lastDayOfMonth
lastDayOfQuarter
lastDayOfWeek
lastDayOfYear
lightFormat
max
milliseconds
millisecondsToHours
millisecondsToMinutes
millisecondsToSeconds
min
minutesToHours
minutesToMilliseconds
minutesToSeconds
monthsToQuarters
monthsToYears
nextDay
nextFriday
nextMonday
nextSaturday
nextSunday
nextThursday
nextTuesday
nextWednesday
parse
parseISO
parseJSON
previousDay
previousFriday
previousMonday
previousSaturday
previousSunday
previousThursday
previousTuesday
previousWednesday
quartersToMonths
quartersToYears
roundToNearestHours
roundToNearestMinutes
secondsToHours
secondsToMilliseconds
secondsToMinutes
set
setDate
setDay
setDayOfYear
setDefaultOptions
setHours
setISODay
setISOWeek
setISOWeekYear
setMilliseconds
setMinutes
setMonth
setQuarter
setSeconds
setWeek
setWeekYear
setYear
startOfDay
startOfDecade
startOfHour
startOfISOWeek
startOfISOWeekYear
startOfMinute
startOfMonth
startOfQuarter
startOfSecond
startOfToday
startOfTomorrow
startOfWeek
startOfWeekYear
startOfYear
startOfYesterday
sub
subBusinessDays
subDays
subHours
subISOWeekYears
subMilliseconds
subMinutes
subMonths
subQuarters
subSeconds
subWeeks
subYears
toDate
transpose
weeksToDays
yearsToDays
yearsToMonths
yearsToQuarters

§Interfaces

AdditionalTokensOptions

Additional tokens options. Used to build function options.

AreIntervalsOverlappingOptions

The areIntervalsOverlapping function options.

DateValues

The date values, used to set or get date object values.

DifferenceInCalendarWeeksOptions

The differenceInCalendarWeeks function options.

DifferenceInHoursOptions

The differenceInHours function options.

DifferenceInMinutesOptions

The differenceInMinutes function options.

DifferenceInQuartersOptions

The differenceInQuarters function options.

DifferenceInSecondsOptions

The differenceInSeconds function options.

DifferenceInWeeksOptions

The differenceInWeeks function options.

Duration

The duration object. Contains the duration in the units specified by the object.

EachDayOfIntervalOptions

The eachDayOfInterval function options.

EachHourOfIntervalOptions

The eachHourOfInterval function options.

EachMinuteOfIntervalOptions

The eachMinuteOfInterval function options.

EachMonthOfIntervalOptions

The eachMonthOfInterval function options.

EachQuarterOfIntervalOptions

The eachQuarterOfInterval function options.

EachWeekOfIntervalOptions

The eachWeekOfInterval function options.

EachYearOfIntervalOptions

The eachYearOfInterval function options.

EndOfWeekOptions

The endOfWeek function options.

FirstWeekContainsDateOptions

The first week contains date options. Used to build function options.

FormatDateOptions

The format function options.

FormatDistanceFnOptions

The FormatDistanceFn function options.

FormatDistanceOptions

The formatDistance function options.

FormatDistanceStrictOptions

The formatDistanceStrict function options.

FormatDistanceToNowOptions

The formatDistanceToNow function options.

FormatDistanceToNowStrictOptions

The formatDistanceToNowStrict function options.

FormatDurationOptions

The formatDuration function options.

FormatISO9075Options

The formatISO9075 function options.

FormatISOOptions

The formatISO function options.

FormatLong

The object with functions that return localized formats. Long stands for sequence of tokens (i.e. PPpp) that allows to define how format both date and time at once. Part of the public locale API.

FormatLongFnOptions

The FormatLongFn function options.

FormatOptions

The format function options.

FormatPart

A format part that represents a token or string literal, used by format parser/tokenizer

FormatRelativeFnOptions

The FormatRelativeFn function options.

FormatRelativeOptions

The formatRelative function options.

FormatRelativeTokenFnOptions

The FormatRelativeTokenFn function options.

FormatRFC3339Options

The formatRFC3339 function options.

FPFn1

FP function interface with 1 arguments.

FPFn2

FP function interface with 2 arguments.

FPFn3

FP function interface with 3 arguments.

FPFn4

FP function interface with 4 arguments.

GenericDateConstructor

The generic date constructor. Replicates the Date constructor. Used to build generic functions.

GetWeekOfMonthOptions

The getWeekOfMonth function options.

GetWeekOptions

The getWeek function options.

GetWeeksInMonthOptions

The getWeeksInMonth function options.

GetWeekYearOptions

The getWeekYear function options.

Interval

An object that combines two dates to represent the time interval.

IntervalOptions

The interval function options.

IntlFormatDistanceOptions

The intlFormatDistance function options.

IntlFormatLocaleOptions

The locale options.

IsMatchOptions

The isMatch function options.

ISOFormatOptions

The ISO format function options. Used to build function options.

IsSameWeekOptions

The isSameWeek function options.

IsThisWeekOptions

The isThisWeek function options.

LastDayOfWeekOptions

The lastDayOfWeek function options.

Locale

The locale object with all functions and data needed to parse and format dates. This is what each locale implements and exports.

LocaleOptions

The locale options.

Localize

The object with functions used to localize various values. Part of the public locale API.

LocalizedOptions

The localized function options. Used to build function options.

LocalizeFnOptions

The LocalizeFn function options.

Match

The object with functions used to match and parse various localized values.

MatchFnOptions

The MatchFn function options.

MatchFnResult

The MatchFn function result.

NearestToUnitOptions

The nearest unit function options. Used to build function options.

NormalizedInterval

A version of Interval that has both start and end resolved to Date.

ParseISOOptions

The parseISO function options.

ParseOptions

The parse function options.

RoundingOptions

The rounding options. Used to build function options.

RoundToNearestHoursOptions

The roundToNearestHours function options.

RoundToNearestMinutesOptions

The roundToNearestMinutes function options.

SetDayOptions

The setDay function options.

SetWeekOptions

The setWeek function options.

SetWeekYearOptions

The setWeekYear function options.

StartOfWeekOptions

The startOfWeek function options.

StartOfWeekYearOptions

The startOfWeekYear function options.

StepOptions

The step function options. Used to build function options.

WeekOptions

The week function options. Used to build function options.

§Type Aliases

Day

The day of the week type alias. Unlike the date (the number of days since the beginning of the month), which begins with 1 and is dynamic (can go up to 28, 30, or 31), the day starts with 0 and static (always ends at 6). Look at it as an index in an array where Sunday is the first element and Saturday is the last.

DurationUnit

The duration unit type alias.

Era

The era. Can be either 0 (AD - Anno Domini) or 1 (BC - Before Christ).

FirstWeekContainsDate

FirstWeekContainsDate is used to determine which week is the first week of the year, based on what day the January, 1 is in that week.

FormatDistanceFn

The function that takes a token (i.e. halfAMinute) passed by formatDistance or formatDistanceStrict and payload, and returns localized distance.

FormatDistanceLocale

The tokens map to string templates used in the format distance function. It looks like this:

FormatDistanceStrictUnit

The unit used to format the distance in formatDistanceStrict.

FormatDistanceToken

The token used in the format distance function. Represents the distance unit with prespecified precision.

FormatDistanceTokenFn

The function used inside the FormatDistanceFn function, implementing formatting for a particular token.

FormatLongFn

The format long function. Formats date, time or both.

FormatLongWidth

The format long width token, defines how short or long the formnatted value might be. The actual result length is defined by the locale.

FormatRelativeFn

The locale function that does the work for the formatRelative function.

FormatRelativeToken

The token used in format relative function. Represents the time unit.

FormatRelativeTokenFn

The locale function used inside the FormatRelativeFn function implementing formatting for a particular token.

FPArity

The supported arity type.

FPFn

FP function interface. It infers the arity of the function and returns the corresponding FP function interface.

FPFnInput

The type of a function that can be converted to FP.

IntlFormatDistanceUnit

The unit used to format the distance in intlFormatDistance.

IntlFormatFormatOptions

The format options (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options)

IntlFormatLocale

The locale string (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).

ISOStringFormat

The ISO string format.

ISOStringRepresentation

The ISO date representation. Represents which component the string includes, date, time or both.

LocaleDayPeriod

Token representing particular period of the day.

LocaleUnit

The units commonly used in the date formatting or parsing.

LocaleUnitValue

The formatting unit value, represents the raw value that can be formatted.

LocaleWidth

The format width. Defines how short or long the formatted string might be. The actaul result length depends on the locale.

LocalizeFn

Individual localize function. Part of Localize.

MatchFn

The match function. Part of Match. Implements matcher for particular unit type.

MatchValueCallback

The function that allows to map the matched value to the actual type.

Month

The month type alias. Goes from 0 to 11, where 0 is January and 11 is December.

NearestHours

Nearest hour type. Goes from 1 to 12, where 1 is the nearest hour and 12 is nearest half a day.

NearestMinutes

Nearest minute type. Goes from 1 to 30, where 1 is the nearest minute and 30 is nearest half an hour.

NearestMinutesOptions deprecated

The nearest minutes function options. Used to build function options.

Quarter

The year quarter. Goes from 1 to 4.

RoundingMethod

The number rounding method.