Anyway to make this simpler?

Hey! I am currently doing something where it will say the local players time if they are in that time zone, so they do not need to convert their time zone to MST themselves, so I can get as many people as possible into my live event.

I don’t want to sit here for an hour and figure this out.

Is there any way to accomplish this 9999999999x easier?

local TimeZone = os.date("%Z")

if TimeZone == "MDT" then
	script.Parent.Text = "Until the Live Event - August 14 at 1:00 PM MST"
elseif TimeZone == "EDT" then
	script.Parent.Text = "Until the Live Event - August 14 at 3:00 PM EDT"
elseif TimeZone == "CDT" then
	script.Parent.Text = "Until the Live Event - August 14 at 2:00 PM CDT"
elseif TimeZone == "PDT" then
	script.Parent.Text = "Until the Live Event - August 14 at 12:00 PM PST"
elseif TimeZone == "UTC" then
	script.Parent.Text = "Until the Live Event - August 14 at 7:00 PM UTC"
end

Thanks, WE

Yes, there are a few ways, however the best way would probably be to store everything in its own table, and loop through the times and determine which one they are in.

local Timezones = {
	['MDT']	= 'Until the Live Event - August 14 at 1:00 PM MST',
	['EDT']	= 'Until the Live Event - August 14 at 3:00 PM EDT',
	['CDT']	= 'Until the Live Event - August 14 at 2:00 PM CDT',
	['PDT']	= 'Until the Live Event - August 14 at 12:00 PM PST',
	['UTC']	= 'Until the Live Event - August 14 at 7:00 PM UTC'
}

local TimeZone = os.date('%Z')
for Time, Text in pairs(Timezones) do
	if TimeZone == Time then
		script.Parent.Text = Text
	end
end
1 Like

That will probablunot help since I want to have it automatically do the time zones. It still has to manually be done by adding things to the table.

I think adding each timezone would be the best approach, as I don’t think it’s possible to do what you’re asking for specifically.

1 Like