1

I am using Lua in Iguana (Interfaceware)

I have server that's located in AEST timezone and I am trying to get time in UTC like this:

   trace(os.time(os.date('!*t'))) 
   trace(os.time(os.date('*t')))
   trace(os.time(os.date('!%c')))

This is the output I am getting:

enter image description here It keeps returning local time instead of UTC.

Am I missing something?

The server is Windows Server 2012.

Egor Skriptunoff
  • 906
  • 1
  • 8
  • 23
arleitiss
  • 107
  • 2
  • 13
  • 1
    Are tables returned by `os.date("!*t")` and `os.date("*t")` contain he same time? What is the output of `print(os.date("!*t").hour, os.date("*t").hour)` ? – Egor Skriptunoff Nov 01 '18 at 09:21
  • @EgorSkriptunoff Yes both tables are identical. And also both contain identical .hour – arleitiss Nov 01 '18 at 09:29
  • Your OS doesn't have correct information about your timezone (wrong settings, absence of synchronization with a time server, etc.). Make the correction manually: `os.time()-11*60*60` – Egor Skriptunoff Nov 01 '18 at 10:09

1 Answers1

0

To get time in UTC use ! :

os.date('!%c')

check your time zone first by this code

local now = os.time()
localtime_minus_UTC = os.difftime(os.time(os.date("*t", now)),
                                  os.time(os.date("!*t", now)))
amin saffar
  • 1,953
  • 3
  • 22
  • 34