I've got time 2014-01-01 06:31:00 UTC.
from above time format I need to extract 06:31:00 in seconds except year:month:date
i.e 2014-01-01 06:31:00 should return 6*60*60+31*60=23460 seconds,
what is the best approach for this
Rails provides Time#seconds_since_midnight:
time = Time.parse("2014-01-01 06:31:00 UTC")
time.seconds_since_midnight
#=> 23460.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With