ios - dateFromString returning nil for 12 hour format irrespective of setting locale to "en_US_POSIX" -


trying date string in particular date format dateformatter.datefrom(string) returning nil. device has 12 hour format. works when changed 24 hour format.i have set locale en_us_posix still not working.can please me issue.

you can try following code:

let dateformatter1 = dateformatter() dateformatter1.locale = nslocale(localeidentifier: "en_us") locale dateformatter1.datestyle = .none dateformatter1.timestyle = .short timefromtext.text = dateformatter1.string(from: fromtimepicker.date) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -