Convert durations in Ruby - hh:mm:ss.sss to milliseconds and vice versa

后端 未结 3 2055
感动是毒
感动是毒 2021-02-15 17:49

I was wondering if there is a built-in method in Ruby that allows me to convert lap times in the format of hh:mm:ss.sss to milliseconds and vice versa. Since I need to do some c

3条回答
  •  渐次进展
    2021-02-15 18:32

    Convert seconds into HH:MM:SS in Ruby

    t = 323 # seconds
    Time.at(t).utc.strftime("%H:%M:%S")
    => "00:03:56"
    

提交回复
热议问题