Is there a way to convert day of week number to day name?

So I’m using os.date, and for my particular project it’s going to be a lot easier to use day of week numbers. However for one text label I want to display the day name, which I really can’t do with my script without converting the numbers I have since I’ve converted the entire in-game time from UTC to EST. I know I could just go through each of the 7 days and define them all individually depending on the day of week number, but that’s sort of a pain and I was wondering if there would be a more efficient way to do this.

1 Like

see me personally… i would manually change the text daily but thats just me

Make a list and just do list[dayofweek]
i think thats what u mean

local Time = os.time({year = 1995, month = 6, day = 1})
local Date = os.date("%A", Time)
print(Date) --Thursday

So June 1st, 1995 was a Thursday.
https://developer.roblox.com/en-us/api-reference/lua-docs/os

1 Like

I don’t think this would work for what I’m doing, since when I’m converting the time to EST I need to make sure the day of the week stays the same from 8:00 - 11:59 pm (since that’s when UTC would be in a different day than us). What I was thinking of was just a more simple way to auto convert day of week numbers (0-6) to the day names (sun - sat) rather than just manually writing them all out. After a bit of testing I just came up with this and it seems to work just an eye sore.

local universalTime = dateTime:ToUniversalTime()
local ESTDay = "Day"
	local UTCDay = os.date("%a")
	if universalTime.Hour == 00 or universalTime.Hour == 01 or universalTime.Hour == 02 or universalTime.Hour == 03 then
		if UTCDay == "Sun" then
			ESTDay = "Sat"
		elseif UTCDay == "Mon" then
			ESTDay = "Sun"
		elseif UTCDay == "Tues" then
			ESTDay = "Mon"
		elseif UTCDay == "Wed" then
			ESTDay = "Tues" 
		elseif UTCDay == "Thurs" then
			ESTDay = "Wed"
		elseif UTCDay == "Fri" then
			ESTDay = "Thurs"
		elseif UTCDay == "Sat" then
			ESTDay = "Fri"
		else
			print("error...")
		end
	else
		ESTDay = UTCDay
	end