Lua - Get current date and time

By xngo on February 22, 2019

-- Current date and time.
local current_unix_timestamp = os.time()
print(current_unix_timestamp)
 
local current_date_time_string = os.date("%Y-%m-%d_%X", current_unix_timestamp)
print(current_date_time_string)

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.