Using dateFormatter in another language [duplicate]
问题 This question already has answers here : NSDateFormatter returns nil in swift and iOS SDK 8.0 (2 answers) Closed 2 years ago . I'm running a piece of code that returns nil when running on an iPhone with a different language setting. An example in code looks like this: let dateFormatter = DateFormatter() dateFormatter.dateFormat = "MMM d, yyyy, h:mm a" let thisDate = "Mar 4, 2017, 7:50 PM" let foundationDate = dateFormatter.string(from: Foundation.Date()) print("As String - thisDate: \