Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift iOS: Parsing of date from a string does not work for some devices. so weird [duplicate]

Tags:

ios

swift

iphone

From the debugger it shows that the date string is "2017-08-01 00:00:00" and I passed the correct format too. But the dateFormatter.date part always fail (return nil) for 1 device. But some its working for simulator and other iphone devices. Im using swift3

enter image description here

iPhone 7 that fails

like image 785
iori24 Avatar asked Oct 09 '17 06:10

iori24


1 Answers

Try to set your locale:

dateFormatter.locale = Locale(identifier: "en_US_POSIX")
like image 162
Ayman Ibrahim Avatar answered Nov 19 '22 16:11

Ayman Ibrahim