Jump to content

[HELP] Converting seconds to minutes : seconds


..:D&G:..

Recommended Posts

Posted

You can use the "modulo" operator (%) like this:

local total_time_in_seconds = 119 
local seconds = total_time_in_seconds % 60   -- returns time in seconds: 59 
local minutes = math.floor(total_time_in_seconds/60)   -- returns time in minutes: 1 
local formatted_str = minutes..":"..seconds 

This means: formatted_str = "1:59" as in minutes:seconds

Posted
You can use the "modulo" operator (%) like this:
local total_time_in_seconds = 119 
local seconds = total_time_in_seconds % 60   -- returns time in seconds: 59 
local minutes = math.floor(total_time_in_seconds/60)   -- returns time in minutes: 1 
local formatted_str = minutes..":"..seconds 

This means: formatted_str = "1:59" as in minutes:seconds

Thanks a lot!

76561198066470453.png

SP37Ecj.jpg?2MTA:Rust Pre-Alpha Build v.0.3:SP37Ecj.jpg?2

https://forum.mtasa.com/viewtopic.php?f=114&t=97848

2Pac: ''Only God can judge me!''

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...