How to update os.date values constantly?

Title.

Right now I’m using this:

while wait(1) do
	local ESTSeconds = os.time() - (3600 * 4)
	local ESTDate = os.date("!*t", ESTSeconds)

	dateString = ESTDate.month.."/"..ESTDate.day.."/"..ESTDate.year
	hourString = tostring(ESTDate.hour > 12 and ESTDate.hour % 12 or ESTDate.hour)
	minuteString = ESTDate.min < 10 and "0"..ESTDate.min or tostring(ESTDate.min)
	period = ESTDate.hour > 12 and "PM" or "AM"

	currentTimeInEST = hourString..":"..minuteString.." "..period.." EST, "..dateString
end

But that just makes the rest of the script not even execute.

Anything below this in the script would not execute because you’re entering an infinite loop.

You need to use the spawn() function so it can run seperately.
e.g.

spawn(function()
    while wait(1) do
        -- stuff
    end
end)
1 Like