Created
February 6, 2019 10:49
-
-
Save lalitlogical/e7ba633f4b1dd377063e5ce60f0471e1 to your computer and use it in GitHub Desktop.
how to convert 270921sec into days + hours + minutes + sec ? (ruby)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = 270921 | |
mm, ss = t.divmod(60) #=> [4515, 21] | |
hh, mm = mm.divmod(60) #=> [75, 15] | |
dd, hh = hh.divmod(24) #=> [3, 3] | |
puts "%d days, %d hours, %d minutes and %d seconds" % [dd, hh, mm, ss] | |
#=> 3 days, 3 hours, 15 minutes and 21 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment