Darky00
Darky00

Reputation: 51

How to print out date and time in this format in Lua?

I want to print out the date and time in this format like so

4/25/2017 12:45 PM 

Upvotes: 2

Views: 4540

Answers (1)

Yu Hao
Yu Hao

Reputation: 122383

os.date has an optional first argument, format, which is used for formatting date and time. e.g.

print(os.date("%m/%d/%Y %I:%M %p"))
-- 04/25/2017 04:39 PM

The detail of the format specifiers is in C's strftime.

Upvotes: 4

Related Questions