-3

What date format I need to process this string? 2017-12-16T07:28:59.629Z

Tried yyyy-MM-dd'T'HH:mm:ssZZZZZ and Tried yyyy-MM-dd'T'HH:mm:sssZZZZZ

Anyway how many s and Z needs end of the format?

dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:sssZZZZZ"
date = dateFormatter.date(from: value as! String)
János
  • 29,667
  • 30
  • 151
  • 300

1 Answers1

2

use the dateformat as

dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"

as the Date Format Patterns suggests that "S" is the format specifier for fractions of seconds.

Anbu.Karthik
  • 80,161
  • 21
  • 166
  • 138