I have a time Gui, but was wondering if there was anyway to abbreviate the roblox time which means changing it to the AM, PM Format instead of Military Time like 16:00?
I think Jailbreak does this somehow.
Script for changing the gui to the time.
while true do
script.Parent.Text = string.sub(game.Lighting.TimeOfDay,1,5)
wait()
This would leave you with a small issue though. When it’s noon it will show up as 0:00. You could fix that by subtracting one before taking the remainder, then adding one back.
To find out if it’s AM or PM using this math approach you would divide by 12 then check if it’s less than 1 for AM otherwise it’s PM. Additionally you could use lists to look it up, or just if statements.
Look into Lighting.ClockTime instead. You don’t have to do string manipulation with this property.
local clockTime = game:GetService("Lighting").ClockTime
local hour = math.floor(clockTime) % 12
local minute = math.floor((clockTime - math.floor(clockTime)) * 60)
local isPM = clockTime >= 12
local timeString = ("%02i:%02i %s"):format(hour, minute, isPM and "PM" or "AM")