Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getRealTime()
  2.     os.loadAPI('json')
  3.  
  4.     local page = http.get('http://worldtimeapi.org/api/timezone/Europe/Berlin')
  5.     local raw = page:readAll()
  6.     local obj = json.decode(raw)
  7.  
  8.     local year = string.sub(obj.datetime, 0, 4)
  9.     local month = string.sub(obj.datetime, 6, 7)
  10.     local day = string.sub(obj.datetime, 9, 10)
  11.     local hour = string.sub(obj.datetime, 12, 13)
  12.     local minutes = string.sub(obj.datetime, 15, 16)
  13.     local seconds = string.sub(obj.datetime, 18, 19)
  14.  
  15.     local time = day .. '.' .. month .. '.' .. year .. ' ' .. hour .. ':' .. minutes .. ':' .. seconds
  16.  
  17.     return time
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement