Faker v0.12.0 Faker.DateTime View Source
Functions for working with DateTime
values.
Link to this section Summary
Functions
Returns a random date in the past up to N days, today not included
Returns a random DateTime between two dates
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(days)
View Source
backward(integer()) :: DateTime.t()
backward(integer()) :: DateTime.t()
Returns a random date in the past up to N days, today not included
Examples
iex> Faker.DateTime.backward(4)
#=> %DateTime{calendar: Calendar.ISO, day: 20, hour: 6,
#=> microsecond: {922180, 6}, minute: 2, month: 12, second: 17,
#=> std_offset: 0, time_zone: "Etc/UTC", utc_offset: 0, year: 2016,
#=> zone_abbr: "UTC"}
Link to this function
between(from, to)
View Source
between(from, to)
View Source
between(
Date.t() | NaiveDateTime.t() | DateTime.t(),
Date.t() | NaiveDateTime.t() | DateTime.t()
) :: DateTime.t()
between( Date.t() | NaiveDateTime.t() | DateTime.t(), Date.t() | NaiveDateTime.t() | DateTime.t() ) :: DateTime.t()
Returns a random DateTime between two dates
Examples
iex> Faker.DateTime.between(~N[2016-12-20 00:00:00], ~N[2016-12-25 00:00:00])
#=> %DateTime{calendar: Calendar.ISO, day: 22, hour: 7,
#=> microsecond: {753572, 6}, minute: 56, month: 12, second: 26,
#=> std_offset: 0, time_zone: "Etc/UTC", utc_offset: 0, year: 2016,
#=> zone_abbr: "UTC"}
Link to this function
forward(days)
View Source
forward(days)
View Source
forward(integer()) :: DateTime.t()
forward(integer()) :: DateTime.t()
Returns a random date in the future up to N days, today not included
Examples
iex> Faker.DateTime.forward(4)
#=> %DateTime{calendar: Calendar.ISO, day: 25, hour: 6,
#=> microsecond: {922180, 6}, minute: 2, month: 12, second: 17,
#=> std_offset: 0, time_zone: "Etc/UTC", utc_offset: 0, year: 2016,
#=> zone_abbr: "UTC"}