2

I am trying to fetch the UTC time as per below code in my Lua script.

local tim = os.time()                                   
local currentUTC = os.date('!%Y-%m-%d-%H:%M:%S', tim)
payload["UTC"] = currentUTC

I am getting below error at the 1st line.

attempt to index a nil value (global 'os')

Please help me in fetching the UTC time without this error.

Sekhar
  • 627
  • 4
  • 14
  • 34
  • 1
    If you destroyed ```os``` in some way you can restore it. With: ```os = require('os')``` - Because all whats in ```package.loaded``` is requireable. – koyaanisqatsi Apr 15 '22 at 15:12
  • Hi @koyaanisqatsi, Thanks a lot. it worked. I have declared like this local os = require ("os") – Sekhar Apr 17 '22 at 16:00

0 Answers0