How do I sync the game time to an real timezone time?

I’m trying to make the game time sync to the Gulf Standard Time [or Dubai time], but I have not found any methods, I tried os.time() and os.date(), but it only works for UTC Time, I also tried DateTime but there isn’t a way to sync the timezone. I know I could get an Http Request but the issues are that it doesn’t work for the client, and rate limits, I am trying to get the time every second, Nothing appears in the output

local Lighting = game:GetService("Lighting")
local RunService = game:GetService("RunService")

RunService.PreRender:Connect(function()
	Lighting.TimeOfDay = os.date("%X")
end)
1 Like

I don’t quite understand

Isn’t that what you want?

Anyway, PreRender is client sided, so you have to put that into a local script. That’s my only guess why its not working

1 Like

It is in a local script

It’s just a mistake I did when making the post, I will get to fix it

1 Like

You can use DateTime and use a bit of math to get the GST Time Zone

local Lighting = game:GetService("Lighting")
local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function()
	local D = DateTime.now()
	local TimeTable = D:ToUniversalTime()
	local HourConvert = TimeTable.Hour + 3
	Lighting.TimeOfDay = HourConvert ..":"..TimeTable.Minute..":"..TimeTable.Second
end)

If you do DateTime.fromUnixTimestamp(os.time()) this is set to UTC time, you can then offset this value by however much you need too - for example -5 hours is os.time() - 18000.

You can view the offset here:

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