-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
  • 32,867
  • 38
  • 193
  • 353

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
  • 82,064
  • 23
  • 174
  • 143