Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Am to Pm gui script not working as interpreted?

i am trying to make a current time gui but what seems to happen is it just shows the 24 hour ratio is it possible to create a script that will find the Am/Pm time?

my code:

while wait() do
	data = os.date('*t')
	script.Parent.Text = data.hour..':'..data.min
end

1 answer

localscript

local TIME_ZONE = 1

while wait(0.1)do
	local date = os.date("!*t")
	local hour = (date.hour + TIME_ZONE) % 24
	local ampm = hour < 12 and "AM" or "PM"
	local timestamp = string.format("i:i %s", ((hour - 1) % 12) + 1, date.min, ampm)
	script.Parent.Text = timestamp --your textlabel or sum
end

11 comments

0

The output i get is i:i 1

0

oh u trying to print it?

0

no i am trying to show it

0

on a textlabel right?

0

yes

0

well that script works for me

0

its in that game

0

just copy paste the script in a localscrip in the textlabel

0

ok thanks

0

did that work?

This discussion is preserved as it was. New answers, comments, and votes are closed.