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

How to convert unix time to other units of time?

The title pretty much explains itself. I need to convert time from the unix epoch into like the year month day or day of the week. LOL, thanks!

1 answer

✓ Accepted answer

This is pretty simple to do actually, all yah have to do is use os.date to get a full table of year, month, weekday, day of the month, day of the year, current hour, current minute, second, ect.

local thing = os.date("*t",os.time())
local ap = ""

if thing.hour > 0 then
	ap = "PM"
else
	ap = "AM"
end

print(thing.day.."/"..thing.month.."/"..thing.year.."  "..math.abs(thing.hour-12)..":"..thing.min.." "..thing.sec.." seconds "..ap)

This will print out the exact time of the os.time() you input in the thing variable. Change os.time() to whatever just make sure it's a unix time. :D

1 comment

0

lol thx

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