This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Separate and sort string
#1
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
Reply
#2
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)
Reply
#3
thanks for the answer it works perfectly.
regards
Reply


Forum Jump: