Logic Machine Forum
ISO 8601 - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: ISO 8601 (/showthread.php?tid=5088)



ISO 8601 - tomnord - 12.11.2023

Is there any way to convert date\time to ISO 8601 format? I need this for a timestamp sting communicating with an api.


RE: ISO 8601 - Erwin van der Zwart - 12.11.2023

Try this:
Code:
function iso_8601_timestamp()
    local now, nowms = os.microtime()
    local ms = math.round(nowms / 1000, 0)
    return os.date("!%Y-%m-%dT%T", now) .. "." .. ms .. "Z"
end

stamp = iso_8601_timestamp()

log(stamp)



RE: ISO 8601 - tomnord - 12.11.2023

worked lika a charm, thank you Erwin.