0

I need an ISO 8601 date formatter With Milliseconds and Timezone in Swift.

Here's a sample date object:

'2017-06-03T01:04:17.826050+00:00'

The documentations seem to require a date with the following format: YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM, which is ISO 8601 if I'm correct.

But attempting to create a DateFormatter with that format doesn't seem to work:

var dateFormatter = DateFormatter()
dateFormatter.dateFormat = "YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM"
dateFormatter.string(from: Date()) 

Which outputs 2017-06-154, which is not the expected format.

The standard ISODateFormatter() also does not output the expected format.

Berry
  • 2,143
  • 4
  • 23
  • 46
  • Where did you find that (wrong) documentation? Here is the right one: http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns – Martin R Jun 03 '17 at 02:03
  • It's the documentation of requirements for the project – Berry Jun 03 '17 at 02:03

0 Answers0