nsdateformatter - Swift: Result of dateFromString nil unexpectely -


i went through related questions , tried suggestions didn't worked out me:

 let dateformatter = nsdateformatter()  dateformatter.dateformat = "dd.mm.yyyy hh:mm"  dateformatter.locale = nslocale(localeidentifier: "en_us_posix")  dateformatter.datestyle = .fullstyle  let timestamp = dateformatter.datefromstring("07.07.2015 19:07") 

timestamp nil.... :-(

remove line nsdateformatterstyle:

let dateformatter = nsdateformatter() dateformatter.dateformat = "dd.mm.yyyy hh:mm" dateformatter.locale = nslocale(localeidentifier: "en_us_posix") let timestamp = dateformatter.datefromstring("07.07.2015 19:07") 

this because setting nsdateformatterstyle overrides dateformatter.dateformat, making results nil when using both.

the solution not use nsdateformatterstyle if have dateformat.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -