Specific Time Zone Textlabel

Hello,

I have tried lookup up how to do this, but i did not understand.

I am trying to get a Textlabel to a specific Time Zone: UTC+0.

Anyone that can help?

Hello!

First, create a LocalScript and place it in the TextLabel

Put this script:

local TextLabel = script.Parent

function UpdateTimeLabel()
    local currentTime = os.date("!%c")
    TextLabel.Text = "UTC+0: " .. currentTime 

end

while true do
    UpdateTimeLabel()
    wait(1)
end

That loop isn’t ideal. Instead, you should probably do this:

local updating = true

while updating do
    UpdateTimeLabel()
    task.wait(1)
end

It’s more accurate and gives you a method of termination incase you need to.
Also, surely you need to use os.time()? I’m not completely educated on the os library, so excuse me.

Sorry i made a mistake, the script works, Thanks but i need it in UTC+2 not UTC+0

How do i fix it to UTC+2?

local TextLabel = script.Parent

function UpdateTimeLabel()
    local currentTime = os.date("!%c", os.time() + 2 * 3600)
    TextLabel.Text = "UTC+2: " .. currentTime 
end

while true do
    UpdateTimeLabel()
    wait(1)
end
1 Like

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