So I’m trying to make a countdown that counts down to a specific time, but adapts to each timezone. For example if you’re in central US time, it counts down to midnight on Dec. 25th, 2020 CST. But if you’re in eastern US time, it reaches the end an hour earlier than it does for the CST players.
I have it set up to print to test it, but the time printed is 12 hours slower than what it should be. I’m in CST, so that’s what timezone the countdown should currently be using. I’m using Christmas to test this because there’s plenty of easily available countdowns online to check if I’m getting the correct time. Here’s a picture of where my countdown should be (the christmas countdown) vs what I’m getting in output:
I’m using a local script in StarterGui, once it’s functional I’ll make it display the time with a Gui. Here’s what I have in the script:
local RunService = game:GetService("RunService")
local targetTime = os.time({year = 2020, month = 12, day = 24, hour = 24, min = 0, sec = 0})
RunService.Heartbeat:Connect( function()
local diffSeconds = targetTime - os.time()
local countdown = os.date('*t', diffSeconds)
if diffSeconds <= 0 then
print("Christmas has arrived")
else
print(('there are %i days, %i hours, %i minutes, and %i seconds until 12:00am on Christmas!'):format(countdown.yday, countdown.hour, countdown.min, countdown.sec))
end
end)