问题描述:

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
相关阅读:
Top