How to know turn os.date("%c") into number

Basically im making a level browser. It has a sorting system, NEWEST and OLDEST. I have the os.date(“%c”) information of when the level was made. And I wanna turn that into a number so I can do: level.LayoutOrder=number. As simple as that.

By the way this is an example of what we get from os.date(“%c”): “Thu Jun 27 15:33:18 2024”

you can maybe use os.time() since it only has numbers

And It’s going to output this:

1719508584
2 Likes

Okay that worked, also is there any way of converting os.time() to os.date?

Yes, there is!
you can use os.date("*t", Time) again to get the time like this

os.date("*t", 1719508584) -- // The time I demonstrated

and it will output this:

{
	["day"] = 27,
	["hour"] = 19,
	["isdst"] = true,
	["min"] = 16,
	["month"] = 6,
	["sec"] = 24,
	["wday"] = 5,
	["yday"] = 179,
	["year"] = 2024
}

I did it a bit differently , thanks for the help though! I did something like this:

local formattedDate = os.date("%d.%m.%Y", creationDate)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.