Show minutes/seconds #3396
-
Beta Was this translation helpful? Give feedback.
Answered by
vitoyucepi
Sep 10, 2023
Replies: 1 comment 1 reply
-
Hi @gAlleb, You can create a function to convert unix time to a custom string pattern. def format_time(time)
int_time = int(time)
seconds = int_time mod 60
result =
if seconds < 10 then
"0#{seconds}"
else
"#{seconds}"
end
minutes = int_time / 60
result =
if minutes < 10 then
"0#{minutes}:#{result}"
else
"#{minutes}:#{result}"
end
result
end
print("#{format_time(116.7)} / #{format_time(184.3)}") Alternativesdef format_time(time)
seconds = int(time mod 60.)
seconds_string =
if seconds < 10 then
"0" ^ string(seconds)
else
string(seconds)
end
minutes = int(time / 60.)
minutes_string =
if minutes < 10 then
"0" ^ string(minutes)
else
string(minutes)
end
minutes_string ^ ":" ^ seconds_string
end
print("#{format_time(116.7)} / #{format_time(184.3)}") |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
gAlleb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @gAlleb,
You can create a function to convert unix time to a custom string pattern.
Consider this code
Alternatives