Search code examples
sirishortcuts

Convert ISO 8601 date+time string to date


I would like to convert a date string from ISO 8601 format (as generated correctly by the "Format Date" block) back to a usable date. I have tried using "Get Dates from Input" but this unfortunately appears not to read the time part correctly.

The flow up to "Format date" yields the string 2018-09-24T11:33:23+02:00, but the "Get Dates from Input" shows 12:00 as the time regardless of when this shortcut is run.

Workflow showing problem

PS: This is a simplified example. The actual date string will be coming from a web service, so I have no control over the incoming format - I need to parse this kind of date to continue with the other things I'm trying to do.


Solution

  • Turns out that the parser works just fine if you replace the T in the ISO format with a space. It even appears to handle the time zone conversion correctly.

    Solution with replace text