generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Minutes + Seconds

Previous Thread :: Next Thread 
Juddily is not online. 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
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
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
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
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 is not online. Juddily
Joined: 24 Aug 2008
Total Posts: 4243
02 Aug 2014 12:44 AM
What would I do for minute/second/millisecond?
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
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 is not online. Juddily
Joined: 24 Aug 2008
Total Posts: 4243
02 Aug 2014 12:49 AM
Oh, thanks.
Report Abuse
Juddily is not online. 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 is not online. 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 is not online. Juddily
Joined: 24 Aug 2008
Total Posts: 4243
02 Aug 2014 01:09 AM
Thanks!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image