I use os.date() to show the unban time in my moderation system. The format string is *t, and it should show my local time, but it doesn’t. If it’s 13:27:00 for me, it shows that time in studio, but in-game it shows 11:27:00. I have tried anything i know of and it doesn’t work. What am I doing wrong.
The code is inside a function in a module script called BanLengthHandler.
Code: (Sorry if it’s a bit messy)
--The if statements are for showing ex. 2022-06-23 instead of 2022-6-23.
-- Look at the returns.
-- I know that there is probably better ways to do this, but this is what i did.
local TimeFinished = StartTime + BanLength -- Unix unban time
local unbanDate = os.date("*t", TimeFinished) -- The date for the unban
if unbanDate["month"] > 9 and unbanDate["day"] > 9 then
return("" .. unbanDate["year"] .. "/" .. unbanDate["month"] .. "/" .. unbanDate["day"] .. " " .. unbanDate["hour"] .. ":" .. unbanDate["min"] .. ":" ..unbanDate["sec"])
elseif unbanDate["month"] < 9 and unbanDate["day"] <9 then
return("" .. unbanDate["year"] .. "/0" .. unbanDate["month"] .. "/0" .. unbanDate["day"] .. " " .. unbanDate["hour"] .. ":" .. unbanDate["min"] .. ":" ..unbanDate["sec"])
elseif unbanDate["month"] < 9 and unbanDate["day"] > 9 then
return("" .. unbanDate["year"] .. "/0" .. unbanDate["month"] .. "/" .. unbanDate["day"] .. " " .. unbanDate["hour"] .. ":" .. unbanDate["min"] .. ":" ..unbanDate["sec"])
elseif unbanDate["month"] > 9 and unbanDate["day"] < 9 then
return("" .. unbanDate["year"] .. "/" .. unbanDate["month"] .. "/0" .. unbanDate["day"] .. " " .. unbanDate["hour"] .. ":" .. unbanDate["min"] .. ":" ..unbanDate["sec"])
end
end