View Source Faker.Date (Faker v0.18.0)

Functions for generating dates

Summary

Functions

Returns a random date in the past up to N days, today not included

Returns a random date between two dates

Returns a random date of birth for a person with an age specified by a number or range

Returns a random date in the future up to N days, today not included

Functions

@spec backward(integer()) :: Date.t()

Returns a random date in the past up to N days, today not included

@spec between(Date.t(), Date.t()) :: Date.t()

Returns a random date between two dates

Examples

iex> Faker.Date.between(~D[2010-12-10], ~D[2016-12-25])
~D[2013-06-07]
iex> Faker.Date.between(~D[2000-12-20], ~D[2000-12-25])
~D[2000-12-20]
iex> Faker.Date.between(~D[2000-02-02], ~D[2016-02-05])
~D[2014-10-23]
iex> Faker.Date.between(~D[2010-12-20], ~D[2010-12-25])
~D[2010-12-21]
Link to this function

date_of_birth(age_or_range \\ 18..99)

View Source
@spec date_of_birth(integer() | Range.t()) :: Date.t()

Returns a random date of birth for a person with an age specified by a number or range

@spec forward(integer()) :: Date.t()

Returns a random date in the future up to N days, today not included