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
refDatenumbernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.

Examples:

date.anytime()
date.anytime(refDate=1)

Example return values:

  • "2025-11-22T12:30:53.535Z"
  • "2026-03-09T05:03:13.667Z"

date.between

Generates a random date between the given boundaries.

ArgTypeRequiredDescription
fromnumbernoStart boundary as a Unix timestamp in milliseconds since epoch.
tonumbernoEnd boundary as a Unix timestamp in milliseconds since epoch.

Examples:

date.between(0, 2000000000000)
date.between(from=1, to=1)

Example return values:

  • "2001-01-03T09:27:56.772Z"
  • "1988-04-02T17:24:17.440Z"

date.betweens

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

ArgTypeRequiredDescription
countnumbernoThe number of dates to generate.
fromnumbernoStart boundary as a Unix timestamp in milliseconds since epoch.
tonumbernoEnd boundary as a Unix timestamp in milliseconds since epoch.

Examples:

date.betweens(2, 0, 2000000000000)
date.betweens(count=1, from=1, to=1)

Example return values:

  • ["1975-03-18T01:28:47.047Z","2005-08-03T07:55:22.524Z"]
  • ["1976-12-05T16:33:40.049Z","1978-06-04T00:02:41.826Z"]

date.birthdate

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

ArgTypeRequiredDescription
refDatenumbernoReference date as a Unix timestamp in milliseconds since epoch used as the generation anchor.
maxnumbernoThe maximum age/year to generate a birthdate for/in.
minnumbernoThe 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()
date.birthdate(refDate=1, max=1, min=1, mode="age")

Example return values:

  • "1955-05-18T19:25:36.178Z"
  • "1993-02-06T15:43:56.865Z"

date.future

Generates a random date in the future.

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

Examples:

date.future()
date.future(refDate=1, years=1)

Example return values:

  • "2026-10-12T16:19:33.811Z"
  • "2026-11-24T03:18:00.421Z"

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:

  • "May"
  • "August"

date.past

Generates a random date in the past.

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

Examples:

date.past()
date.past(refDate=1, years=1)

Example return values:

  • "2025-11-21T11:30:51.789Z"
  • "2026-02-13T14:19:21.153Z"

date.recent

Generates a random date in the recent past.

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

Examples:

date.recent()
date.recent(days=1, refDate=1)

Example return values:

  • "2026-05-17T13:46:00.558Z"
  • "2026-05-17T22:45:20.752Z"

date.soon

Generates a random date in the near future.

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

Examples:

date.soon()
date.soon(days=1, refDate=1)

Example return values:

  • "2026-05-18T15:47:09.312Z"
  • "2026-05-19T10:48:13.424Z"

date.timeZone

Returns a random IANA time zone relevant to this locale.

No parameters.

Examples:

date.timeZone()

Example return values:

  • "Europe/Amsterdam"
  • "America/Juneau"

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:

  • "Thursday"
  • "Tuesday"