Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Time.now会产生类似的东西:
Time.now
2013-07-24 22:23:08 -0700
我想:
2013-07-24 22:23:08
用于随后进入数据库。一定很简单,但我没有在Time docs中找到它。写作Time.now.to_s[0..19]听起来像是糟糕的编程。
Time.now.to_s[0..19]
你可以通过
Time.now.to_formatted_s(:db)
您可以从这里找到 to_formatted_s 的不同格式
或者
Time.now.strftime("%F %T")
希望这可以帮助你