-
What do you want to achieve?
I’m trying to make a new years countdown. -
What is the issue?
For some reason when I use tick() in a local script to update the countdown, the results are different in studio and in game.
- My current time is 7:50 AM, the UTC time for me is 4:50 AM.
- When I use
tick()
and convert it to hours usingos.date()
it returns 10:50 AM
This is the script I’m using:
Local script in game.StarterPlayer.StarterPlayerScripts
-- Expiry date: 2048 xD
local monthLengths = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local leapYears = {2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048}
local daysT = game.Workspace.Screen.UiPart.SurfaceGui.Days.Num
local hoursT = game.Workspace.Screen.UiPart.SurfaceGui.Hours.Num
local minsT = game.Workspace.Screen.UiPart.SurfaceGui.Minutes.Num
local secsT = game.Workspace.Screen.UiPart.SurfaceGui.Seconds.Num
while true do
local currentTime = tick()
local second = tonumber(os.date("%S", currentTime))
local minute = tonumber(os.date("%M", currentTime))
local hour = tonumber(os.date("%H", currentTime))
local day = tonumber(os.date("%d", currentTime))
local month = tonumber(os.date("%m", currentTime))
print(hour)
daysT.Text = monthLengths[month] - day
hoursT.Text = 23 - hour
minsT.Text = 59 - minute
secsT.Text = 59 - second
wait(0.1)
end
-
What solutions have you tried so far?
I’ve tried using different methods of making the time such as manually formatting the raw tick() but that didn’t change the results.
Edits: I just tested it again on Studio, the hour is also 10 AM on studio.