Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 1.10 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Ruby, Rails and difference between two dates
  2. ruby-1.9.2-p0 >   DateTime.now
  3.  => Mon, 14 Feb 2011 20:02:49 +0100
  4. ruby-1.9.2-p0 > User.first.created_at
  5.  => Tue, 04 May 2010 07:03:24 CEST +02:00
  6. ruby-1.9.2-p0 > DateTime.now-User.first.created_at
  7. TypeError: expected numeric or date
  8.     from /Users/Jacob/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/date.rb:1356:in `-'
  9.     from /Users/Jacob/.rvm/gems/ruby-1.9.2-p0@loyaltric_template/gems/activesupport-3.0.3/lib/active_support/core_ext/date/calculations.rb:98:in `minus_with_duration'
  10.     from (irb):47
  11.     from /Users/Jacob/.rvm/gems/ruby-1.9.2-p0@loyaltric_template/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
  12.     from /Users/Jacob/.rvm/gems/ruby-1.9.2-p0@loyaltric_template/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
  13.     from /Users/Jacob/.rvm/gems/ruby-1.9.2-p0@loyaltric_template/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
  14.     from script/rails:6:in `require'
  15.     from script/rails:6:in `<main>'
  16. ruby-1.9.2-p0 >
  17.        
  18. DateTime.now - User.first.created_at.to_datetime
  19.        
  20. Time.now - User.first.created_at