How do I get the current time in UTC

Hello, I was wondering how you would make some kind of live event thing. I mostly just need help with getting the time in a certain time zone. I’ve read through the documentation but I still don’t fully understand it.

Thank you.

print(os.date("!*t")) -- prints the current time in UTC
-- example usage
local utc_time = os.date("!*t") -- the current time in UTC

local day = utc_time.day -- the day of the month
local month = utc_time.month -- the month (integer)
local year = utc_time.year -- the year 

print("today is", string.format("%s/%s/%s", day, month, year)) 
-- prints (as of writing this) 
-- "today is 22/12/2020"

-- you could use a different date/string format

Alternatively, you can use DateTime

2 Likes

Okay, I’ll check it out, thanks!

1 Like