Converting a time number into bigger time number

Hey there,

I’m trying to convert like the Berezza method but I want to turn a number like

13,000 milliseconds into 13 S and 60,000 milliseconds into 1 Minute and etc to years and even more.

How can I do this?

use math.floor() for minutes and then take away the amount of minutes to seconds. For example:

local totalTime = 73
local minutes = math.floor(73/60)
local seconds = totalTime - (minutes*60)

Wit this, you can add on and roundify with math.floor() until years.

Sorry but I don’t really understand how can I go to hours and days with this shematic…

Something like this?

local totalTime = 87000
local days = math.floor(totalTime/24)
local hours = math.floor(totalTime/60)
local minutes = math.floor(totalTime/60)
local seconds = math.floor(totalTime/1000)
local milliseconds = totalTime - (seconds*1000)

It should looks like this? ;-:

Basically, math.floor() rounds a number so, 3.4 will be 3 after math.floor() Days and hours from seconds would be:

local totalTime = 100000
local days = math.floor(totalTime/86400)
local hours = math.floor(totalTime-(days*86400)/3600)

for more reference, you can read this: https://developer.roblox.com/en-us/api-reference/lua-docs/math and find math.floor()

and the numbers I used to divide are the amount of seconds of this item.

For milliseconds I have to do :

totalTime = 100000
local days = math.floor(totalTime/86400*1000)
local hours = math.floor(totalTime - (days*(86400*1000) / 3600 * 1000)
local minutes = math.floor(totalTime - (days*(86400*1000) + hours*(3600*1000) / 60 * 1000)
local seconds = math.floor(totalTime - (days*(86400*1000) + hours*(3600*1000) + minutes * (60*1000) / 1000)
local milliseconds = totalTime - (days*(86400*1000) + hours*(3600*1000) + minutes * (60*1000) + seconds * 1000)

that’s it?

Yes, that’s right. Years stack up the same way.

And how should I return the obtained String?

The returned items are integers, and remote events is a good way.

You can probably look into this instead: https://developer.roblox.com/en-us/api-reference/lua-docs/os

No it’s not what I’m looking for

I think i will make a function into my TextLabel local script wich shows the value of the time (it is a currency)

So at the end of this function I wrote upper,
Is it possible to return totalTime?
Will it works?

You can return totalTime and convert locally. I’m not sure to understand what you mean.

Something like this

local function AbbreviateTimeNumber(Number)
 local days = math.floor(Number/86400*1000)
 local hours = math.floor(Number - (days*(86400*1000) / 3600 * 1000)
 local minutes = math.floor(tNumber - (days*(86400*1000) + hours*(3600*1000) / 60 * 1000)
 local seconds = math.floor(Number - (days*(86400*1000) + hours*(3600*1000) + minutes * (60*1000) / 
 1000)
 local milliseconds = Number - (days*(86400*1000) + hours*(3600*1000) + minutes * (60*1000) + seconds * 1000)

 return Number
end

So number will be something like 13 Days?

I think you should return everything. Number will still be the amount you entered in front of the function.

local plr = game:GetService("Players").LocalPlayer
local Timestamps = plr.PlayerInfo.Timestamps

script.Parent.Text = Timestamps.Value

Timestamps:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = Timestamps.Value
end)

This is my script, I want to replace the milliseconds by shorter number like days etc… by calling the function I wrote and the text will be equal to the returned value

so let’s say 100000 miliseconds, it will be shortened to x years, y days, etc.? If so, the best way would be returning everything, or returning a string with all the values.

Yeah that’s the idea
(30 chars

Ok so I have to return the highest (idk how to call it (days / hours / etc…) and to add a coma “,” and to add the second one so,

If you have 3 days and 7 hours you want the script to do

local returnedNumber = days…","…hours…" Days"

So it will return “3,7 Days”

It should be something like this:

if years == 0 and days == 0 then --if statement to know which category to class
return days+"".."days, "..hours+"".."hours, " --etc
elseif 
end

Hope this helps, sorry for late response tho