How can I create a day and time GUI?

I am trying to make a working digital clock GUI with the current in-game day and time. (e.g. Sun 12:00 PM). I have currently gotten the actual time part working and the AM/PM part after the time, but I cannot get the current day to display.

This is the current code which makes the time display and I want to make days also display.

local Gui = script.Parent
local Lighting = game:GetService("Lighting")

function getLightingTime()
	local totalMinutes = game.Lighting:GetMinutesAfterMidnight()
	local hours = math.floor(totalMinutes / 60)
	local minutes = math.floor(totalMinutes % 60)
	local period
	if hours < 12 then
		period = "AM"
		period = "PM"
		hours -= 12
	if hours == 0 then
		hours = 12
	return string.format("%02d:%02d %s", hours, minutes, period)

while true do
	Gui.Text = getLightingTime()

I have also already created a working Day/Night cycle script which works correctly with the script above.

Any help would be appreciated!

%a gives you abbreviated weekday name such as Wed
%A gives you full weekday name such as Wednesday

You can use this code like this,"%a") or"%A")

1 Like