How to convert os.time() (unix time) to an actual date?

Hello!
So, I’m wondering how would I get date and time (sec,min,hour,day,…) from Unix Epoch time.
For example, how would I convert this: 1582379858 to Sat, 22 Feb 2020 13:58:19 GMT ← Not exactly like that, just to get some values like sec,min,hour,day,month,year,…

I’ve seen some posts with scripts that do that, but I also saw, that they mentioned, os.date was not a feature at that time.

Thank you!

This is a bit complicated, but once you got all the numbers and stuff (how many days make up a year, how much make up a specific month, a week, and such). This is going to be a very complicated process, but you are gonna have to try dividing that long string of numbers into years, months, weeks, days, hours, minutes, and seconds, and stuff.

It’s hard for me to explain all of this due to complication, but I guess you’re looking for date and time without using os.date()? Is that correct?

4 Likes

With a little bit of converting (e.g. on the weekday, converting 6 to Saturday, etc.), you could use os.date()

https://developer.roblox.com/en-us/api-reference/lua-docs/os

6 Likes

Well, I’ve actually found the solution for what I wanted (I saw you were typing when I replied to my post that I got something but it wasn’t accurate - I was wrong, it was accurate, I was looking at wrong time when checking on another website).
Basically, I only wanted something like that os.date("!*t",lastOnline)["hour"],
but still Thank you for your help!

1 Like

Also, is there a way to convert date into unix time?

Also, is there a way to get unix time from os.date?

os.time(date)

https://www.lua.org/pil/22.1.html

5 Likes