New Year Script not matching with my time

I’m trying to make a new years countdown script but realized that the counter works BUT it doesn’t match the timezone that I’m currently in… How do I fix this?

local newYear = os.time({year = os.date("%Y", os.time() + (365*24*60*60) - (24*60*60)), month = 1, day = 1})


while wait(1) do
	
	local currentTime = os.time()
	
	local timeDiff = newYear - currentTime
	
	
	local d = math.floor(timeDiff/60/60/24)
	local h = string.format("%0.2i", math.floor((timeDiff - (d*60*60*24))/60/60))
	local m = string.format("%0.2i", math.floor((timeDiff - (d*60*60*24) - (h*60*60))/60))
	local s = string.format("%0.2i", timeDiff - (d*60*60*24) - (h*60*60) - (m*60))
	local formattedTime = d .. ":" .. h .. ":" .. m .. ":" .. s
	
	script.Parent.Clock.ClockGui.TimeToNewYear.Text = timeDiff <= 0 and "00:00:00:00" or formattedTime
	
	if timeDiff <= 0 then

		break
	end
end
1 Like

Replace currentTime with tick().

tick() returns the local time in UNIX epoch.

You can use os.date() together with os.time() to get a player’s local time.

local Time = os.date("*t", os.time())
print(Time.hour, Time.min, Time.sec)

This is also saves you having to calculate the seconds, minutes etc. yourself. :wink:

1 Like

see this article and it will solve the problem

1 Like

You can use local date = os.date("*t", os.time()) on the client which gets the local time of the current client.

1 Like

This didn’t really help me because it still doesn’t match with my time. Also, how do I match the UTC time to mine? (Mine is UTC -5)

then use PAGOTATZIS2’s method

So do I just replace the current time with that?

You misunderstood him, he wants a time specifically on his timezone, not by server time.

Are you trying to apply different timezones for each client? or apply your own to every client?

I’m trying to apply it just to my timezone (so EST)

local hours = 5
--os.time() returns the number of seconds since the unix timestamp
local seconds = os.time()-hours*3600 --an hour has 3600 seconds
local date = os.date("!*t", seconds)

print(date.year, date.month, date.day, date.hour, date.min, date.sec)

tick() is not the server time.