I want to set the video playback time (HH: MM: SS) to seconds, and vice versa.

HH: MM: SS in seconds

#rails c or require
require "active_support/duration"

duration_text = "00:01:00"
Time.parse(duration_text) - Time.parse("00:00:00") # => 60.0

Seconds to HH: MM: SS

Time.at(60).utc.strftime("%H:%M:%S") # => "00:01:00"

Recommended Posts

I want to set the video playback time (HH: MM: SS) to seconds, and vice versa.
[Ruby] I want to make an array from a character string with the split method. And vice versa.
I want to set the conditions to be displayed in collection_check_boxes
I want to bring Tomcat to the server and start the application
I want to call a method and count the number
I want to give edit and delete permissions only to the poster
I want to return to the previous screen with kotlin and java!
Glassfish tuning list that I want to keep for the time being
[Ruby] I want to extract only the value of the hash and only the key
I want to pass the argument of Annotation and the argument of the calling method to aspect
I translated the grammar of R and Java [Updated from time to time]
[Java] How to set the Date time to 00:00:00
I want to control the start / stop of servers and databases with Alexa
I want you to use Scala as Better Java for the time being
I want to get only the time from Time type data ...! [Strftime] * Additional notes
I want to recursively get the superclass and interface of a certain class
I want to output the day of the week
Set the time of LocalDateTime to a specific time
I want to truncate after the decimal point
I want to get the value in Ruby
Rspec: I want to test the post-execution state when I set a method on subject
I want to morphologically analyze the log in the DB and put it in the DB to classify messages 1
[Android Studio] I want to set restrictions on the values registered in EditText [Java]
I want to hit the API with Rails on multiple docker-composes set up locally