Skip to main content

date Domain

The date domain maps domain keywords to underlying faker implementations.

Faker Documentation

Methods

date.anytime

Generates a random date that can be either in the past or in the future.

ArgTypeRequiredDescription
refDateintegernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.

Examples:

date.anytime()

Example return values:

  • "2026-12-25T08:55:20.593Z"

date.between

Generates a random date between the given boundaries.

ArgTypeRequiredDescription
fromintegernoStart boundary as a Unix timestamp in milliseconds since epoch.
tointegernoEnd boundary as a Unix timestamp in milliseconds since epoch.

Examples:

date.between(0, 2000000000000)

Example return values:

  • 2026-01-15T12:34:56.000Z

date.betweens

Generates random dates between the given boundaries. The dates will be returned in an array sorted in chronological order.

ArgTypeRequiredDescription
countintegernoThe number of dates to generate.
fromintegernoStart boundary as a Unix timestamp in milliseconds since epoch.
tointegernoEnd boundary as a Unix timestamp in milliseconds since epoch.

Examples:

date.betweens(2, 0, 2000000000000)

Example return values:

  • ["2026-01-15T12:34:56.000Z","2026-02-01T09:00:00.000Z"]

date.birthdate

Returns a random birthdate. By default, the birthdate is generated for an adult between 18 and 80 years old.

ArgTypeRequiredDescription
refDateintegernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.
maxintegernoThe maximum age/year to generate a birthdate for/in.
minintegernoThe minimum age/year to generate a birthdate for/in.
modestringnoEither 'age' or 'year' to generate a birthdate based on the age or year range.

Examples:

date.birthdate(refDate=20000, max=69, min=16, mode="age")

Example return values:

  • "1966-09-18T08:47:31.333Z"

date.future

Generates a random date in the future.

ArgTypeRequiredDescription
refDateintegernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.
yearsintegernoThe range of years the date may be in the future.

Examples:

date.future()

Example return values:

  • "2027-02-07T18:41:48.525Z"

date.month

Returns a random name of a month.

ArgTypeRequiredDescription
abbreviatedbooleannoWhether to return an abbreviation.
contextbooleannoWhether to return the name of a month in the context of a date. In the currently supported locale this has no visible effect. This option is mainly relevant for future multi-locale support (for example, locale-specific grammar/capitalization differences).

Examples:

date.month()
date.month(abbreviated=false, context=false)

Example return values:

  • February

date.past

Generates a random date in the past.

ArgTypeRequiredDescription
refDateintegernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.
yearsintegernoThe range of years the date may be in the past.

Examples:

date.past()

Example return values:

  • "2025-07-01T11:48:55.347Z"

date.recent

Generates a random date in the recent past.

ArgTypeRequiredDescription
daysintegernoThe range of days the date may be in the past.
refDateintegernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.

Examples:

date.recent()

Example return values:

  • "2026-04-27T23:46:16.707Z"

date.soon

Generates a random date in the near future.

ArgTypeRequiredDescription
daysintegernoThe range of days the date may be in the future.
refDateintegernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.

Examples:

date.soon()

Example return values:

  • "2026-04-29T11:09:09.211Z"

date.timeZone

Returns a random IANA time zone relevant to this locale.

No parameters.

Examples:

date.timeZone()

Example return values:

  • Europe/Stockholm

date.weekday

Returns a random day of the week.

ArgTypeRequiredDescription
abbreviatedbooleannoWhether to return an abbreviation.
contextbooleannoWhether to return the day of the week in the context of a date. In the currently supported locale this has no visible effect. This option is mainly relevant for future multi-locale support (for example, locale-specific grammar/capitalization differences).

Examples:

date.weekday()
date.weekday(abbreviated=false, context=false)

Example return values:

  • Tuesday