当前位置: 动力学知识库 > 问答 > 编程问答 >

In Ruby/Rails, how do I convert time duration (in string format) into milliseconds?

问题描述:

I”m using Rails 4.2.3. I have a time (duration) in the format

HH:MM:SS

For instance, “5:14:32” (5 hours, 14 minutes, and 32 seconds). What can I do to take the string and convert it into milliseconds?

网友答案:

You can do it this way:

Time.parse("5:14:32").seconds_since_midnight * 1000 # 18872000.0
分享给朋友:
您可能感兴趣的文章:
随机阅读: