views:

49

answers:

2

I need it for an unit test... how to get a time.now in the same format as active record returns for a datetime field?

+1  A: 
Time.now.strftime("%Y-%m-%d %H:%M:%S")
floatless
no, the time form activerecord has UTC too
tapioco123
A: 

The UTC is probably added by Rails itself. Have you checked at your database console how exactly is stored the date?

Anyway, a shorter way to do the above is Time.now.to_s(:db), but what you're probably looking for is Time.now.to_formatted_s :rfc822 (Documentation here)

Chubas