Generates a random date that can be either in the past or in the future.
Optional
options: { refDate?: string | number | Date }The optional options object.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Generates a random date between the given boundaries.
The options object.
The early date boundary.
The late date boundary.
Generates random dates between the given boundaries. The dates will be returned in an array sorted in chronological order.
The options object.
Optional
count?: number | { max: number; min: number }The number of dates to generate.
The early date boundary.
The late date boundary.
faker.date.betweens({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z' })
// [
// '2022-07-02T06:00:00.000Z',
// '2024-12-31T12:00:00.000Z',
// '2027-07-02T18:00:00.000Z'
// ]
faker.date.betweens({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z', count: 2 })
// [ '2023-05-02T16:00:00.000Z', '2026-09-01T08:00:00.000Z' ]
faker.date.betweens({ from: '2020-01-01T00:00:00.000Z', to: '2030-01-01T00:00:00.000Z', count: { min: 2, max: 5 }})
// [
// 2021-12-19T06:35:40.191Z,
// 2022-09-10T08:03:51.351Z,
// 2023-04-19T11:41:17.501Z
// ]
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.
Optional
options: { refDate?: string | number | Date }The options to use to generate the birthdate.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Returns a random birthdate for a given age range.
The options to use to generate the birthdate.
The maximum age to generate a birthdate for.
The minimum age to generate a birthdate for.
'age'
to generate a birthdate based on the age range.
It is also possible to generate a birthdate based on a 'year'
range.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Returns a random birthdate in the given range of years.
The options to use to generate the birthdate.
The maximum year to generate a birthdate in.
The minimum year to generate a birthdate in.
'year'
to generate a birthdate based on the year range.
It is also possible to generate a birthdate based on an 'age'
range.
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.
Optional
options: The options to use to generate the birthdate.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
The maximum age/year to generate a birthdate for/in.
The minimum age/year to generate a birthdate for/in.
Either 'age'
or 'year'
to generate a birthdate based on the age or year range.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Only used when mode
is 'age'
.
Generates a random date in the future.
Optional
options: { refDate?: string | number | Date; years?: number }The optional options object.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Optional
years?: numberThe range of years the date may be in the future.
Generates a random date in the past.
Optional
options: { refDate?: string | number | Date; years?: number }The optional options object.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Optional
years?: numberThe range of years the date may be in the past.
Generates a random date in the recent past.
Optional
options: { days?: number; refDate?: string | number | Date }The optional options object.
Optional
days?: numberThe range of days the date may be in the past.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Generates a random date in the near future.
Optional
options: { days?: number; refDate?: string | number | Date }The optional options object.
Optional
days?: numberThe range of days the date may be in the future.
Optional
refDate?: string | number | DateThe date to use as reference point for the newly generated date.
Module to generate dates (without methods requiring localized data).