【发布时间】:2013-06-20 12:21:16
【问题描述】:
我试图让我的应用程序将时间显示为毫秒(例如 11:37:53.231),但 1.8.7 中的 strftime 似乎没有选项(http://ruby-doc.org/core-1.8.7/Time.html#method-i-strftime) .在 Ruby >= 1.9.3 中,有 %3N 选项 (http://ruby-doc.org/core-1.9.3/Time.html#method-i-strftime),但它不在 1.8.7 的文档中,而且似乎也不起作用。
这是我在 Ruby 1.8.7 中得到的输出。
cur_time = Time.now
# => Mon Jun 24 12:43:14 +0900 2013
cur_time.strftime('%H:%M:%S.%3N')
# => "12:43:14.%3N"
有其他解决方案吗?不幸的是,不能迁移到 1.9.3。
【问题讨论】: