Faker v0.12.0 Faker.Date View Source

Functions for generating dates

Link to this section 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

Link to this section Functions

Link to this function

backward(days) View Source
backward(integer()) :: Date.t()

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

Link to this function

between(from, to) View Source
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
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

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