ios - How to convert date which is having String type to NSDate? -
this question has answer here:
- how convert string nsdate? 1 answer
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
Post a Comment