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?
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)
You didn’t read my full response
Oh you mean the time of day? but what does %X mean
As @bolzpy’s screenshot of the documentation shows, %X formats it into the HH:MM:SS format that you want
But is the os.time() in UTC because it seems to be in my timezone? My timezone is UTC + 8
local Time = os.date("*t", os.time())
Use google.
Manually setting is quite inconvinient. You can use “*t” to get the current players timezone though this is only callable on the client.
Are you running it on the server or on the client?
When run from the server, it will tell you the EST time.
When did they say they wanted to get the player’s timezone? They said they wanted to get the current EST time.
Ohhhhhhhhh… My brain is drunk.
The script is on a server script and I just ran it
@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
Do it in a Roblox server, not in studio
@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
When run on the server, os.time() returns the UTC time.
When run on the client, os.time() returns the local time.
Yeah, but os.date()
works anywhere, it should be used instead, especially if you only need to know the time on the client.
So is this code correct or I need to follow what @SeargentAUS said which is to go and do it in the Roblox server?