Skip to main content

Date

ฦฌ Date: Format["YYYY-MM-DD"] & string

An Iso.Date represents a calendar date. "Calendar date" refers to the concept of a date as expressed in everyday usage, independent of any time zone. For example, it could be used to represent an event on a calendar which happens during the whole day no matter which time zone it's happening in.

Iso.Date refers to the whole of a specific day; if you need to refer to a specific time on that day, use Iso.DateTime. An Iso.Date can be converted into a Iso.ZonedDateTime by combining it with a Iso.Time and Iso.TimeZone using the toZonedDateTime() function. It can also be combined with a Iso.Time to yield a "zoneless" Iso.DateTime using the toDateTime() method.

Iso.YearMonth and Iso.MonthDay carry less information than Iso.Date and should be used when complete information is not required.

Defined in

iso-types.ts:66

now

โ–ธ now(timeZone?): Date

This method gets the current calendar date according to the system settings. Optionally a time zone can be given in which the time is computed, instead of the current system time zone.

Parameters

NameTypeDescription
timeZone?stringThe time zone to get the current date and time in, as a string. If not given, the current system time zone will be used.

Returns

Date

an Iso.Date string representing the date.

Defined in

types/IDateFns.ts:16


fromNumbers

โ–ธ fromNumbers(year, month, day): Date

Parameters

NameType
yearnumber
monthnumber
daynumber

Returns

Date

Defined in

types/IDateFns.ts:17


isValid

โ–ธ isValid(date): date is Date

Parameters

NameType
dateunknown

Returns

date is Date

Defined in

types/IDateFns.ts:18


assertIsValid

โ–ธ assertIsValid(date): asserts date is Date

Parameters

NameType
dateunknown

Returns

asserts date is Date

Defined in

types/IDateFns.ts:19


getYear

โ–ธ getYear(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:20


getMonth

โ–ธ getMonth(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:21


getDay

โ–ธ getDay(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:22


getDayOfWeek

โ–ธ getDayOfWeek(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:23


getDayOfYear

โ–ธ getDayOfYear(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:24


getWeekOfYear

โ–ธ getWeekOfYear(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:25


getDaysInMonth

โ–ธ getDaysInMonth(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:26


getDaysInYear

โ–ธ getDaysInYear(date): number

Parameters

NameType
dateDate

Returns

number

Defined in

types/IDateFns.ts:27


inLeapYear

โ–ธ inLeapYear(date): boolean

Parameters

NameType
dateDate

Returns

boolean

Defined in

types/IDateFns.ts:28


with

โ–ธ with(dateTime, temporalDateLike, options?): Date

Parameters

NameType
dateTimeDate
temporalDateLikeObject
temporalDateLike.day?number
temporalDateLike.month?number
temporalDateLike.year?number
options?Object
options.overflow?TemporalOverflow

Returns

Date

Defined in

types/IDateFns.ts:29


add

โ–ธ add(date, temporalDurationLike, options?): Date

Parameters

NameType
dateDate
temporalDurationLikeDuration | { years?: number ; months?: number ; weeks?: number ; days?: number ; hours?: number ; minutes?: number ; seconds?: number ; milliseconds?: number }
options?Object
options.overflow?TemporalOverflow

Returns

Date

Defined in

types/IDateFns.ts:40


subtract

โ–ธ subtract(date, temporalDurationLike, options?): Date

Parameters

NameType
dateDate
temporalDurationLikeDuration | { years?: number ; months?: number ; weeks?: number ; days?: number ; hours?: number ; minutes?: number ; seconds?: number ; milliseconds?: number }
options?Object
options.overflow?TemporalOverflow

Returns

Date

Defined in

types/IDateFns.ts:56


until

โ–ธ until(date, other, options?): Duration

Parameters

NameType
dateDate
otherDate
options?Object
options.largestUnit?TemporalSingularUnit | TemporalPluralUnit | "auto"
options.smallestUnit?TemporalSingularUnit | TemporalPluralUnit
options.roundingIncrement?number
options.roundingMode?TemporalRoundingMode

Returns

Duration

Defined in

types/IDateFns.ts:72


since

โ–ธ since(date, other, options?): Duration

Parameters

NameType
dateDate
otherDate
options?Object
options.largestUnit?TemporalSingularUnit | TemporalPluralUnit | "auto"
options.smallestUnit?TemporalSingularUnit | TemporalPluralUnit
options.roundingIncrement?number
options.roundingMode?TemporalRoundingMode

Returns

Duration

Defined in

types/IDateFns.ts:82


equals

โ–ธ equals(date, other): boolean

Parameters

NameType
dateDate
otherDate

Returns

boolean

Defined in

types/IDateFns.ts:92


isEqual

โ–ธ isEqual(date, other): boolean

alias for equals

Parameters

NameType
dateDate
otherDate

Returns

boolean

Defined in

types/IDateFns.ts:96


isBefore

โ–ธ isBefore(date, other): boolean

Parameters

NameType
dateDate
otherDate

Returns

boolean

Defined in

types/IDateFns.ts:97


isAfter

โ–ธ isAfter(date, other): boolean

Parameters

NameType
dateDate
otherDate

Returns

boolean

Defined in

types/IDateFns.ts:98


isEqualOrBefore

โ–ธ isEqualOrBefore(date, other): boolean

Parameters

NameType
dateDate
otherDate

Returns

boolean

Defined in

types/IDateFns.ts:99


isEqualOrAfter

โ–ธ isEqualOrAfter(date, other): boolean

Parameters

NameType
dateDate
otherDate

Returns

boolean

Defined in

types/IDateFns.ts:100


toDateTime

โ–ธ toDateTime(date, time?): DateTime

Parameters

NameType
dateDate
time?Time

Returns

DateTime

Defined in

types/IDateFns.ts:101


toZonedDateTime

โ–ธ toZonedDateTime(date, item): ZonedDateTime

Parameters

NameType
dateDate
itemstring | { timeZone: string ; time?: Time }

Returns

ZonedDateTime

Defined in

types/IDateFns.ts:102


toYearMonth

โ–ธ toYearMonth(date): YearMonth

Parameters

NameType
dateDate

Returns

YearMonth

Defined in

types/IDateFns.ts:103


toMonthDay

โ–ธ toMonthDay(date): MonthDay

Parameters

NameType
dateDate

Returns

MonthDay

Defined in

types/IDateFns.ts:104


getFields

โ–ธ getFields(date): DateSlots

Parameters

NameType
dateDate

Returns

DateSlots

Defined in

types/IDateFns.ts:105


from

โ–ธ from(item, options?): Date

Parameters

NameType
itemany
options?Object
options.overflowTemporalOverflow

Returns

Date

Defined in

types/IDateFns.ts:106


compare

โ–ธ compare(one, two): number

Parameters

NameType
oneDate
twoDate

Returns

number

Defined in

types/IDateFns.ts:107


format

โ–ธ format(date, format): string

summary Format the ZonedDateTime.

description Return the formatted ZonedDateTime string in the given format.

The characters wrapped between two single quotes characters (') are escaped. Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. (see the last example)

Format of the string is based on Unicode Technical Standard #35: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table with a few additions (see note 7 below the table).

Accepted patterns:

UnitPatternResult examplesNotes
EraG..GGGAD, BC
GGGGAnno Domini, Before Christ1
GGGGGA, B
Calendar yeary44, 1, 1900, 20174
yo44th, 1st, 0th, 17th4,5
yy44, 01, 00, 174
yyy044, 001, 1900, 20174
yyyy0044, 0001, 1900, 20174
yyyyy...2,4
Extended yearu-43, 0, 1, 1900, 20174
uu-43, 01, 1900, 20174
uuu-043, 001, 1900, 20174
uuuu-0043, 0001, 1900, 20174
uuuuu...2,4
QuarterQ1, 2, 3, 4
Qo1st, 2nd, 3rd, 4th5
QQ01, 02, 03, 04
QQQQ1, Q2, Q3, Q4
QQQQ1st quarter, 2nd quarter, ...1
QQQQQ1, 2, 3, 43
MonthM1, 2, ..., 12
Mo1st, 2nd, ..., 12th5
MM01, 02, ..., 12
MMMJan, Feb, ..., Dec
MMMMJanuary, February, ..., December1
MMMMMJ, F, ..., D
ISO week of yearI1, 2, ..., 535
Io1st, 2nd, ..., 53th5
II01, 02, ..., 535
Day of monthd1, 2, ..., 31
do1st, 2nd, ..., 31st5
dd01, 02, ..., 31
ISO day of weeki1, 2, 3, ..., 75
io1st, 2nd, ..., 7th5
ii01, 02, ..., 075
iiiMon, Tue, Wed, ..., Sun5
iiiiMonday, Tuesday, ..., Sunday1,5
iiiiiM, T, W, T, F, S, S5
iiiiiiMo, Tu, We, Th, Fr, Sa, Su5
Long localized dateP04/29/14535
PPApr 29, 14535
PPPApril 29th, 14535
PPPPFriday, April 29th, 14531,5

Notes:

  1. Any sequence of the identical letters is a pattern, unless it is escaped by the single quote characters (see below). If the sequence is longer than listed in table (e.g. EEEEEEEEEEE) the output will be the same as default pattern for this unit, usually the longest one (in case of ISO weekdays, EEEE). Default patterns for units are marked with "2" in the last column of the table.

    format("2017-11-06", 'MMM') //=> 'Nov'

    format("2017-11-06", 'MMMM') //=> 'November'

    format("2017-11-06", 'MMMMM') //=> 'N'

    format("2017-11-06", 'MMMMMM') //=> 'November'

    format("2017-11-06", 'MMMMMMM') //=> 'November'

  2. Some patterns could be unlimited length (such as yyyyyyyy). The output will be padded with zeros to match the length of the pattern.

    format("2017-11-06", 'yyyyyyyy') //=> '00002017'

  3. QQQQQ could be not strictly numerical in some locales. These tokens represent the shortest form of the quarter.

  4. The main difference between y and u patterns are B.C. years:

    Yearyu
    AC 111
    BC 110
    BC 22-1

    Also yy always returns the last two digits of a year, while uu pads single digit years to 2 characters and returns other years unchanged:

    Yearyyuu
    10101
    141414
    37676376
    1453531453
  5. These patterns are not in the Unicode Technical Standard #35:

    • i: ISO day of week
    • I: ISO week of year
    • o: ordinal number modifier
    • P: long localized date
    • p: long localized time
  • Characters are escaped using single quote symbols (').

example

// Represent 11 February 2014 in middle-endian format:
var result = format("2014-02-11", 'MM/dd/yyyy')
//=> '02/11/2014'

Parameters

NameTypeDescription
dateDatethe original date
formatstringthe string of tokens

Returns

string

the formatted date string

Defined in

types/IDateFns.ts:234


chain

โ–ธ chain(date): IDateChain

Parameters

NameType
dateDate

Returns

IDateChain

Defined in

types/IDateFns.ts:235