Could someone who isn't in GMT / UTC time test this code for me?

So I made some code to get UTC time.
(I am in UTC time btw)
So when I try it, it works, but when I change my computer’s internal clock, the time changes as well.

You can just run it in the studio and tell me the output.


local function check(x1)
	local str = x1
	local var = "th"
	local sec = string.sub(str,-1,-1)
	if sec == "1" then
		var = "st"
	elseif sec == "2" then
		var = "nd"
	elseif sec == "3" then
		var = "rd"
	end

	return(str..var)
end

local exchange = {
	[1]	= "January",
	[2] = "February",
	[3] = "March",
	[4] = "April",
	[5] = "May",
	[6] = "June",
	[7] = "July",
	[8] = "August",
	[9] = "September",
	[10] = "October",
	[11] = "November",
	[12] = "December"
}

local function execute()

	local utc_time = os.date("!*t")

	local day = utc_time.day
	local month = utc_time.month
	local year = utc_time.year
	local hour = utc_time.hour
	local min = utc_time.min

	if #tostring(hour) == 1 then
		hour = ("0"..hour)
	end


	local newday = check(tostring(day))
	local newmonth = exchange[month]

	local final = (newday.." "..newmonth.. " "..year.." - "..hour..":"..min)
	return final
end

print(execute())

Thanks


(Time Zone: Philippine standard timezone[PST])

Oh nice, so it works!
Thanks
[filler text for character limit]

1 Like

wrong category go to #help-and-feedback:code-review

This works. Pretty coooooool.
(Time Zone: Eastern Standard Time[EST])