Apidog Docs
🇺🇸 English
  • 🇺🇸 English
  • 🇯🇵 日本語
HomeLearning CenterSupport CenterAPI References
HomeLearning CenterSupport CenterAPI References
Discord Community
Slack Community
X / Twitter
🇺🇸 English
  • 🇺🇸 English
  • 🇯🇵 日本語
  1. Learning Center
  • Back to home
  • Dynamic values Modules
  • Airline
  • Animal
  • Color
  • Commerce
  • Company
  • Database
  • Datatype
  • Date
  • Finance
  • Food
  • Git
  • Hacker
  • Helpers
  • Image
  • Internet
  • Location
  • Lorem
  • Music
  • Number
  • Person
  • Phone
  • Science
  • String
  • System
  • Vehicle
  • Word
  1. Learning Center

Date

Module to generate dates.
Overview
To quickly generate a date in the past, use recent() (last day) or past() (last year). To quickly generate a date in the future, use soon() (next day) or future() (next year). For a realistic birthdate for an adult, use birthdate().
For more control, any of these methods can be customized with further options, or use between() to generate a single date between two dates, or betweens() for multiple dates.
You can generate random localized month and weekday names using month() and weekday().

anytime#

Generates a random date that can be either in the past or in the future.
Parameters
NameTypeDefaultDescription
refDatestring | number | Date{{$date.now}}The date to use as reference point for the newly generated date.
Returns: Date
Examples

between#

Generates a random date between the given boundaries.
Parameters
NameTypeDefaultDescription
fromstring | number | DateThe early date boundary.
tostring | number | DateThe late date boundary.
Returns: Date
Examples

betweens#

Generates random dates between the given boundaries. The dates will be returned in an array sorted in chronological order.
Parameters
NameTypeDefaultDescription
countnumber | { min: number; max: number; }3The number of dates to generate.
fromstring | number | DateThe early date boundary.
tostring | number | DateThe late date boundary.
Returns: Date
Examples

birthdate#

Returns a random birthdate. By default, the birthdate is generated for an adult between 18 and 80 years old. But you can customize the 'age' range or the 'year' range to generate a more specific birthdate.
Parameters
NameTypeDefaultDescription
refDatestring | number | Date{{$date.now}}The date to use as reference point for the newly generated date.
maxnumberThe maximum age/year to generate a birthdate for/in.
minnumberThe minimum age/year to generate a birthdate for/in.
mode'age' | 'year'Either 'age' or 'year' to generate a birthdate based on the age or year range.
refDatestring | number| Date{{$date.now}}The date to use as reference point for the newly generated date. Only used when mode is 'age'.
Returns: Date
Examples

future#

Generates a random date in the future.
Parameters
NameTypeDefaultDescription
refDatestring | number | Date{{$date.now}}The date to use as reference point for the newly generated date.
yearsnumber1The range of years the date may be in the future.
Returns: Date
Examples

month#

Returns a random name of a month.
Parameters
NameTypeDefaultDescription
abbreviatedbooleanfalseWhether to return an abbreviation.
contextbooleanfalseWhether to return the name of a month in the context of a date. In the default en locale this has no effect, however, in other locales like fr or ru, this may affect grammar or capitalization, for example 'январь' with { context: false } and 'января' with { context: true } in ru.
Returns: Date
Examples

past#

Generates a random date in the past.
Parameters
NameTypeDefaultDescription
refDatestring | number | Date{{$date.now}}The date to use as reference point for the newly generated date.
yearsnumber1The range of years the date may be in the past.
Returns: Date
Examples

recent#

Generates a random date in the recent past.
Parameters
NameTypeDefaultDescription
daysnumber1The range of days the date may be in the past.
refDatestring | number | Date{{$date.now}}The date to use as reference point for the newly generated date.
Returns: Date
Examples

soon#

Generates a random date in the near future.
Parameters
NameTypeDefaultDescription
daysnumber1The range of days the date may be in the future.
refDatestring | number | Date{{$date.now}}The date to use as reference point for the newly generated date.
Returns: Date
Examples

timeZone#

Returns a random IANA time zone name.
The returned time zone is not tied to the current locale.
Returns: string
Examples

weekday#

Returns a random day of the week.
Parameters
NameTypeDefaultDescription
abbreviatedbooleanfalseWhether to return an abbreviation.
contextbooleanfalseWhether to return the day of the week in the context of a date. In the default en locale this has no effect, however, in other locales like fr or ru, this may affect grammar or capitalization, for example 'Lundi' with { context: false } and 'lundi' with { context: true } in fr.
Returns: string
Examples

Previous
Datatype
Next
Finance
Built with