Time.now in activerecord format
I need it for an unit test... how to get a time.n开发者_高级运维ow in the same format as active record returns for a datetime field?
Time.now.strftime("%Y-%m-%d %H:%M:%S")
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)
精彩评论