Unsure of how to convert seconds into minutes

I don’t know the way of converting (seconds) into a formatted minutes instead,
I want this to convert seconds into minutes so it can display the Minutes (meant to be converted but I’m unsure of what to do)

So far I have this.

function Format(Int)
	return string.format("%02i", Int)
end

function Convert(Seconds)
	local Minutes = (Seconds - Seconds%60)/60
	Seconds = Seconds - Minutes*60
	local Hours = (Minutes - Minutes%60)/60
	Minutes = Minutes - Minutes*60
	return Format(Hours).." H :"..Format(Minutes).." M :"..Format(Seconds).." S"
end

I tried looking for it but it seems like I couldn’t find a way.
Can someone please tell me what I might need to do?

Not asking for a code but asking for guidance of what I should look for.
(Notify me if you find a page related.)

2 Likes

your code is from here:

I have even used it before so… What exactly is the issue? It works

Do you just want minutes and seconds?

1 Like
function Format(Int)
	return string.format("%02i", Int)
end

function convertToHMS(Seconds)
	local Minutes = (Seconds - Seconds%60)/60
	
	
	
	Seconds = Seconds - Minutes*60
	
	return Format(Minutes)..":"..Format(Seconds)
end

print(convertToHMS(3601))

will print 60:01

all you needed to do was remove anything related to hours out of the function

2 Likes

Random suggestion but to make your life a tad bit easier you can also use floor division (//)

print(120//60) -- prints 2
print(110//60) -- prints 1
1 Like

I want the function basically to change the Seconds to Minutes instead of it just detecting seconds like,

10 Seconds, then once changed it’ll consider it 10 Minutes instead and not 00:10.

1 Like

That’s a thing??? Holy Jesus that’s nice

1 Like

So you want it like this?

“5m 2s” (5 minutes 2 seconds)
or
“5m” (5 minutes)

basically like it to be 5m and 2s but, when I’m doing
convert(60 seconds)
i want it to instead make the 60 seconds being converted to be like
converted - now 60 seconds = 60 minutes.

Found the solution 2 days ago.