Jacob Lenn Posted July 28, 2013 Posted July 28, 2013 Hello. How can i replace dot (".") with ":"? String.gsub doesn't work to me. I converted sec to minutes and i have sth like 1.23 and i want 1:23. Hope u can help me.
Jacob Lenn Posted July 28, 2013 Author Posted July 28, 2013 Resolved. I found this: function sec2min(sSeconds) local nSeconds = tonumber(sSeconds) if nSeconds == 0 then --return nil; return "00:00"; else nHours = string.format("%02.f", math.floor(nSeconds/3600)); nMins = string.format("%02.f", math.floor(nSeconds/60 - (nHours*60))); nSecs = string.format("%02.f", math.floor(nSeconds - nHours*3600 - nMins *60)); return nMins..":"..nSecs end end
bandi94 Posted July 28, 2013 Posted July 28, 2013 try to convert the sec's and hour's in difrent variable's. (local sec = ,local hour =) in "String.gsub" the dot "." , as pattern mean's all character's so you will have ":::"
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now