Ruby: Convert time to seconds?

后端 未结 8 729
甜味超标
甜味超标 2020-12-28 08:16

How can I convert a time like 10:30 to seconds? Is there some sort of built in Ruby function to handle that?

Basically trying to figure out the number of seconds fro

8条回答
  •  清歌不尽
    2020-12-28 08:30

    Yet another implementation:

    Time.now.to_i - Date.today.to_time.to_i # seconds since midnight
    

提交回复
热议问题