Lua os.date() - What's the difference between *t and !*t

Viewed 1216

The first argument passed to os.date() is the format string. I've seen people use *t and !*t as the format string.

Is there a difference between the two?

1 Answers

The lua ref manual describes this:

If format starts with '!', then the date is formatted in Coordinated Universal Time

These two examples show the difference:

local t = os.date( "!%a %b %d, %H:%M")
print(t) -- Thu Oct 25, 04:01 (current UTC)

local t = os.date( "%a %b %d, %H:%M")
print(t) -- Thu Oct 25, 12:01
Related