Created
October 24, 2014 12:43
-
-
Save passalini/3a84478ee5bdbfc1b112 to your computer and use it in GitHub Desktop.
Milliseconds to timestamp
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
# based in http://stackoverflow.com/a/10874157 | |
def to_timestamp(x) | |
y = 60*60*1000 | |
h = x/y | |
m = (x-(h*y))/(y/60) | |
s = (x-(h*y)-(m*(y/60)))/1000 | |
mi = x-(h*y)-(m*(y/60))-(s*1000) | |
string = "#{h.to_s.rjust(2, '0')}:#{m.to_s.rjust(2, '0')}:#{s.to_s.rjust(2, '0')},#{mi.to_s.rjust(3, '0')}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment