开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜