Converting server os.time() value to local players time

I’m developing a game with announcements that have a timestamp linked to them, how can I convert the UTC os.time() from the server to display the timestamp at when it was posted in their os.time()

E.g “hi” - posted at 5:30PM (For UTC players) to
“hi” - posted at 1:30PM (For EST players)

This may help you, https://scriptinghelpers.org/questions/71460/how-to-get-a-players-local-time-getservice-roblox-api

function GetClientTime(utc)
    local UTC_CurrentTime = os.time()
    local Client_CurrentTime = math.floor(tick())
    local diff = Client_CurrentTime - UTC_CurrentTime
    return utc + diff
end

-- Usage

local o = os.time {year = 2020; month = 6; day = 14; hour = 5} -- 5AM today in UTC time
local client_Time = GetClientTime(o) -- client's time at the above time in UTC
4 Likes