Making a live event in EST timezone

Hello! I’m looking to make a live event system that uses the EST timezone instead of the UTC.

I’ve tried to subtract 5 hours in seconds to the UNIX timestamp. But it just says 31 days instead of 2 hours remaining.

Server script:

local panel = workspace:WaitForChild("Panel")

local gui = panel.Gui

local module = require(game.ReplicatedStorage.LiveEvent)

-- this should be on EST
local eventTime = os.time({
	year = 2021, 
	month = 12, 
	day = 11,
	hour = 20,
	min = 10, 
	sec = 0
})

gui.time.Text = os.date("!%x", eventTime) .. " " .. os.date("!%X", eventTime)

while task.wait(1) do
	local est = module:GetEST()
	
	local diff = eventTime - est
	
	gui.left.Text = module:TimeLeft(diff)
end

Module script:

local ls = {}

function ls:TimeLeft(sec)
	local dt = os.date("!*t", sec)
	local d = tostring(dt["day"])
	local h = tostring(dt["hour"])
	local m = tostring(dt["min"])
	local s = tostring(dt["sec"])
	
	return d .. " Days and " .. h .. " hours and " .. m .. " minutes and " .. s .. " seconds left."
end

function ls:GetEST()
	local currentTime = os.time() - 18000

	return currentTime
end

function ls:FormatEST()
	local est = ls:GetEST()
	
	local formatted = os.date("!%X", est)

	return formatted
end

return ls

How it looks in game:
17f022b4e0c7267e66a65e8a3cfdee05

I don’t believe it is possible to do that. But what you can do to display est is:

  • Maybe use UTC, but then display EST, so like take the UTC, and then put it in a variable,
    subtract 5 hours and display it like that.

I think i fixed it. I had to change the time left function to get the display right.

So convert seconds into days, hours, minutes and seconds.

I found the solution here Converting seconds into days, hours, minutes and seconds - GeeksforGeeks.

function ls:TimeLeft(sec)
	local d = sec / (24 * 3600)

	sec = sec % (24 * 3600)

	local h = sec / 3600

	sec %= 3600
	
	local m = sec / 60 

	sec %= 60
	
	local s = sec
	
	return tostring(math.floor(d)) .. " Days and " .. tostring(math.floor(h)) .. " hours and " .. tostring(math.floor(m)) .. " minutes and " .. tostring(math.floor(s)) .. " seconds left."
end

Subtracting on the difference didn’t work so instead i added 5 hours.

local diff = (eventTime - est) + 18000

And it worked.

a24e24fac4ad5da14a17e3919019d28e

1 Like