Method: Faker::Time.forward

Defined in:
lib/faker/default/time.rb

.forward(days: 365, period: :all, format: nil) ⇒ Time

Produce a random time in the future (up to N days).

Examples:

Faker::Time.forward(days: 23, period: :morning)
  # => "2014-09-26 06:54:47 -0700"
Faker::Time.forward(days: 5,  period: :evening, format: :long)
  #=> "October 21, 2018 20:47"

Parameters:

  • (defaults to: 365)

    The maximum number of days to go into the future.

  • (defaults to: :all)

    The time of day, if any. See TIME_RANGES.

  • (defaults to: nil)

    The name of a DateTime format to use.

Returns:



95
96
97
# File 'lib/faker/default/time.rb', line 95

def forward(days: 365, period: :all, format: nil)
  time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
end