0

I'm currently able to get the Trello due date, giving me this string:

2018-10-22T16:00:00.000Z

I'd like to get the time until then in the format HH:MM:SS as a string.

With normal Lua, I imagine it wouldn't be too hard, but with the restricted use of things like os.time, I'm quite confused on how to do it. Thanks for any help!

Universal Link
  • 307
  • 1
  • 14

1 Answers1

1

string.match can extract your date and time, the following code will give you each value in a variable to use. reference:sting.match wiki

str = "2018-10-22T16:00:00.000Z"
-- Extract date
local year, month, day = str:match("(%d+)-(%d+)-(%d+)")
print(year, month, day) -- 2018, 10, 22
-- Extract Time
local hour, min, sec = str:match("(%d+):(%d+):(%d+)")
print(hour, min, sec) -- 16, 00, 00
-- or more like your requirement
print(string.format('%.2d:%.2d:%.2d', hour, min, sec)) -- 16:00:00
wsha
  • 874
  • 2
  • 9
  • 25