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?
Both will achieve the same outcome
Btw, I am just curious, what does {}
mean
It’s called string formatting. You can put a variable inside the brackets and it will display it in the string.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.