How to get current time utc, gmt etc

i have made code similar to this topic:

but i want to get current time like mine like GMT+8 not GMT+0
and know if it is PM or AM

current code

-- // services \\ --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Shared = ReplicatedStorage.Shared
local SecondsToTime = require(Shared.SecondsToTime)

-- // objects \\ --
local TimeText = script.Parent.CurrentTime

-- // events \\ --
RunService.RenderStepped:Connect(function()
	local GMT = os.date("!*t", os.time())
	
	TimeText.Text = GMT.hour..":" ..GMT.min
end)
1 Like

not all players in roblox have the same time and i dont only want GMT+8 i want every player’s time to be correct

Example:
if their time is GMT+7 and it shows GMT+8 then it’d be 7 pm for their time in their phone or pc but in the game it is 8 pm

if 11:59 am is done then 12:00 pm is pm its basically a 12 hour time not 24 hour time

How’s this?

local function formatTime(use12Hour, t )
	local t = t or tick()
	
	local hours = math.floor(t / 3600) % 24
	local mins = math.floor(t / 60) % 60
	local secs = t % 60
	
	local isPm = hours > 12
	local amOrPm = isPm and "pm" or "am"
	
	--convert to 12 hour time if we want to use 12 hour time instead of 24: 
	if use12Hour then
		hours = isPm and hours - 12 or hours
		return string.format("%d:%02d:%02d"..amOrPm, hours, mins, secs)
	else
		return string.format("%d:%02d:%02d ", hours, mins, secs)
	end
end

print(formatTime(true))

image

6 Likes

good actually i want to know of what it prints

1 Like

How would I change the timezone to EST?