views:

58

answers:

1

I'm comparing two DateTime objects (at least I think I am, they look slightly different in the console output below).

p DateTime.now
p current_user.created_at #schema.rb states that this is a datetime field
difference = DateTime.now - current_user.created_at
p difference

Console output

Mon, 04 Oct 2010 22:56:32 +1000
Sat, 14 Aug 2010 20:51:08 EST +10:00

Error (on the difference = DateTime.now - current_user.created_at line)

expected numeric or date

What am I doing wrong? Thanks for reading.

+2  A: 

Try Time.zone.now (http://railsapi.com/doc/rails-v3.0.0/classes/ActiveSupport/TimeWithZone.html).

Yannis