How to get Client time (hours:minutes:seconds)

Alright so as the title say i would like the get the client’s time in hms format (hours:minute:seconds)
Untill now i was using this code :

local function getTime(sec)
	return ("%.2d:%.2d:%.2d"):format(sec/3600%24, sec/60%60, sec%60)
-- would return : xx:xx:xx  | eq : 16:53:37

but it doesn’t get the actual Client’s time (for me it’s 1 hour late - fixed eq would be : 17:53:37 and no i’m not gonna as +1 dont answer that pls it might be different for others)
Help ! also maybe i’ve misunderstood something if so then please explain me :slight_smile:
btw important detail i want to get it on the server but it deosn’t matter much after all cuz we can always get it from clien side and transfer it to server so nvm not so important


first off tick() is deprecated

you can try using os.clock() or os.time() i dont remember which one gets the os’s time.


Well i didn’t knew tick() was deprecated but it does not fix my issue tho i obtained
Times that are still wrong… even after trying os.clock() and os.time() perhaps my code is wrong to begin with

1 Like

maybe, i never reached moduluses in my math class so im not familliar with them, i dont think i can further help you :frowning:

1 Like

Alright ! thanks you for trying :slight_smile: imma do some more researches see if i can find anyone else that have been meeting this issue

1 Like

os.time or run on a LocalScript will give you local time. Also, tick is not deprecated.

Roblox Time
Roblox Tick


Alternatively, you can use the DateTime library.

local localTime =

local hour = localTime.Hour
local minutes = localTime.Minute
local seconds = localTime.Second

print(`Current time: {hour}:{minutes}:{seconds}`)

Found out the way with and %H%M%S Specifiers thanks

1 Like works too thanks i was a little confused at first on how we could use DateTime that’s why i didn’t tried it yet anyways thanks!


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.