Logic Machine Forum
Separate and sort string - 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: Separate and sort string (/showthread.php?tid=3439)



Separate and sort string - JRP - 24.06.2021

I have a string in ISO 8601 format: 2021-06-23T20: 16: 16.000 + 02: 00
But I want it in the format: 06-23-2021, 20:16:16.
How could I do it?

Greetings


RE: Separate and sort string - admin - 24.06.2021

Use this:
Code:
date = '2021-06-23T20:12:16'
year, month, day, hour, min, sec = date:match('(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)')
res = string.format('%s-%s-%s, %s:%s:%s.', day, month, year, hour, min, sec)
log(res)



RE: Separate and sort string - JRP - 24.06.2021

thanks for the answer it works perfectly.
regards