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.
我正在开发一个 Rails 3 应用程序,我需要以这种确切的格式显示给定的时间(以秒为单位):
0 hours, 3 minutes and 39 seconds
现在我将它显示为 00:03:39。
我怎样才能做到这一点?
感谢所有帮助!
你可以这样做:
seconds = 219 hours = seconds / 3600 seconds -= hours * 3600 minutes = seconds / 60 seconds -= minutes * 60 puts "#{hours} hours, #{minutes} minutes and #{seconds} seconds"