Timezone in roblox

Hello! Does anyone know how to get the exact EST time on Roblox Studio? If so, can anyone please teach me how to do it?

1 Like

You could get the epoch time, via os.time(). Then, because that time is for UTC, you subtract 5 hours worth of seconds

so ETC Time would be os.time() - 5 * 3600.

If you want it as a time of day, then you use os.date() as well:

local Time = os.date("%X", os.time() - 5 * 3600)
3 Likes


but this is the output it came and I want it in a 24 hour clock like 14:35

1 Like

You didn’t read my full response

1 Like

Oh you mean the time of day? but what does %X mean

1 Like

5 Likes

As @bolzpy’s screenshot of the documentation shows, %X formats it into the HH:MM:SS format that you want

2 Likes

But is the os.time() in UTC because it seems to be in my timezone? My timezone is UTC + 8

1 Like
local Time = os.date("*t", os.time()) 

Use google.

1 Like

Manually setting is quite inconvinient. You can use “*t” to get the current players timezone though this is only callable on the client.

1 Like

Are you running it on the server or on the client?
When run from the server, it will tell you the EST time.
image
image

1 Like

When did they say they wanted to get the player’s timezone? They said they wanted to get the current EST time.

1 Like

Ohhhhhhhhh… My brain is drunk.

1 Like

The script is on a server script and I just ran it

1 Like

@SeargentAUS Here is the code and the results

while true do
	wait(1)
	local Time = os.date("%X", os.time() - 5 * 3600)
	print(Time)
end

1 Like

Do it in a Roblox server, not in studio

1 Like

@SeargentAUS
os.time() returns the local time, not UTC.

You can use os.date.

Code:

while task.wait(1) do
	local Time = os.date("!*t", os.time() - 5 * 3600)
	print(`{Time.hour}:{Time.min}:{Time.sec}`)
end
1 Like

When run on the server, os.time() returns the UTC time.
When run on the client, os.time() returns the local time.

This has already been expressed previously in the thread.

1 Like

Yeah, but os.date() works anywhere, it should be used instead, especially if you only need to know the time on the client.

2 Likes

So is this code correct or I need to follow what @SeargentAUS said which is to go and do it in the Roblox server?

1 Like