ios - How to convert date which is having String type to NSDate? -


this question has answer here:

i developing ios app using swift. accessing data server , returning data in json format. in having field 'expirydate' getting json , converted string follows:

var validitydate = offerelements[indexpath.row]["enddate"].stringvalue 

it returning date of following format:

2015-08-24t00:00:00.000z 

i wanna convert mm/dd/yyyy, how can ?

your suggestions welcome. thank in advance.

this should work minimal or no changes

    func datefromstring(datestring: string) -> nsdate {         let dateformatter = nsdateformatter()         dateformatter.dateformat = "yyyy-mm-dd't'hh:mm:ss.sssz"          return dateformatter.datefromstring(datestring)!     } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -