ios - How to format string in Swift using strftime -


edit: please read need support specific format, cannot go , use hardcoded format using nsdateformatter

hi i've got task format dates in our app using settings retrieved our api, format in case supported strftime functions.

how should go , use these in swift.

example format date , time: "date_format": "%d %b %y" "time_format": "%h:%m"

i found strtime function i'm not sure how should use or if should. i've found examples in objective-c

i hope can find better way satisfy requirement, here's code.

let buffersize = 255 var buffer = [int8](count: buffersize, repeatedvalue: 0) var timevalue = time(nil) let tmvalue = localtime(&timevalue)  strftime(&buffer, uint(buffersize), "%d %b %y", tmvalue) let dateformat = string(cstring: buffer, encoding: nsutf8stringencoding)!  strftime(&buffer, uint(buffersize), "%h:%m", tmvalue) let timeformat = string(cstring: buffer, encoding: nsutf8stringencoding)! 

note: updated code bit clarity.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -