Skip to content

Instantly share code, notes, and snippets.

@operator-DD3
Created July 24, 2014 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save operator-DD3/813765f564fb3ff614c3 to your computer and use it in GitHub Desktop.
Save operator-DD3/813765f564fb3ff614c3 to your computer and use it in GitHub Desktop.
Lua Date Problem. These values, I thought, should be equal. 'a' is 6 hours behind 'b'.
local a = os.date('%c')
local b = os.date('!%a %b %d %H:%M:%S %Y')
print('Date: ' .. a)
print('UTC: ' .. b)
@operator-DD3
Copy link
Author

Can anybody tell me what's going on here? Why don't the 2 strings match? How can I make them match? Do I subtract the 6 hours for my timezone and update the date? That seems a little hackish.

When I use os.date('%!c') the ! tells it to format date in UTC, which it does, but returns time and date from the Zero time zone.

@operator-DD3
Copy link
Author

I still don't understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment