Skip to content

Instantly share code, notes, and snippets.

@fatosmorina
Created April 28, 2019 08:22
Show Gist options
  • Save fatosmorina/1c227b1e350beeda13fc4290a8eb7ed8 to your computer and use it in GitHub Desktop.
Save fatosmorina/1c227b1e350beeda13fc4290a8eb7ed8 to your computer and use it in GitHub Desktop.
start_time = Time.new(2013,1)
end_time = Time.new(2014,1)
TimeDifference.between(start_time, end_time).in_years
=> 1.0
TimeDifference.between(start_time, end_time).in_months
=> 12.0
TimeDifference.between(start_time, end_time).in_weeks
=> 52.14
TimeDifference.between(start_time, end_time).in_days
=> 365.0
TimeDifference.between(start_time, end_time).in_hours
=> 8760.0
TimeDifference.between(start_time, end_time).in_minutes
=> 525600.0
TimeDifference.between(start_time, end_time).in_seconds
=> 31536000.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment