Skip to content

Instantly share code, notes, and snippets.

@emmanuel
Created July 24, 2011 22:26
Show Gist options
  • Save emmanuel/1103188 to your computer and use it in GitHub Desktop.
Save emmanuel/1103188 to your computer and use it in GitHub Desktop.
ruby-1.9.2-p180 :005 > dt1 = 1.year.ago.to_datetime
=> Sat, 24 Jul 2010 15:26:20 -0700
ruby-1.9.2-p180 :006 > dt2 = DateTime.current
=> Sun, 24 Jul 2011 15:26:25 -0700
ruby-1.9.2-p180 :007 > dt2 - dt1
=> (31536004999579/86400000000)
ruby-1.9.2-p180 :008 > (dt2 - dt1).to_i
=> 365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment