Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 02 Aug 2014 12:22 AM |
How would I turn seconds into minutes with a remainder of seconds? Like, 346 seconds would return as 5:46
I know I have to use %, and I've done this before a really long time ago, but right now my math brain is pooping out on me really hard and I'm having trouble figuring it out how to do it. |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 12:27 AM |
local function GetTime(seconds) -- Returns the time in 24hr hh:mm:ss form return ("%.2i:%.2i:%06.3f"):format( (seconds/3600)%24, (seconds/60)%60, seconds%60 ) end
Or if you just wanted the minutes:
local function GetTime(seconds) -- Returns the time in mm:ss form return ("%.2i:%.2i:%06.3f"):format( (seconds/60)%60, seconds%60 ) end |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 12:29 AM |
If you don't want miliseconds, replace the strings with "%.2i:%.2i:%.2i" for the top one and ""%.2i:%.2i" for the bottom one
Also I messed up the bottom one WITH miliseconds anyways: "%.2i:%06.3f" |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 02 Aug 2014 12:44 AM |
| What would I do for minute/second/millisecond? |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 12:48 AM |
local function GetTime(seconds) -- Returns the time in mm:ss form return ("%.2i:%06.3f"):format( (seconds/60)%60, seconds%60 ) end |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
| |
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
|
| 02 Aug 2014 12:52 AM |
| Would it be possible to have it be mm:ss:ms isntead of mm:ss.ms? |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 02 Aug 2014 01:07 AM |
local function GetTime(seconds) return ("%.2i:%06.3f"):format( (seconds/60)%60, seconds%60 ):gsub("%.", ":") end
This is basically the same thing I just added the gsub to replace . with : |
|
|
| Report Abuse |
|
|
Juddily
|
  |
| Joined: 24 Aug 2008 |
| Total Posts: 4243 |
|
| |
|