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