Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format string in Objective C

How can i format a string like "Fri Oct 17 00:00:00 +0200 2003" to a simple date string like Fri Oct 17 2003?

Is there any easy solution?

like image 276
phx Avatar asked Dec 07 '22 04:12

phx


2 Answers

Yes, use the NSDateFormatter to parse the first into an NSDate and then use another NSDateFormatter to write out that NSDate in the second format.

like image 151
Stefan Arentz Avatar answered Jan 02 '23 16:01

Stefan Arentz


You can find a list of the date format specifiers here: Unicode Date Formats

like image 27
nall Avatar answered Jan 02 '23 16:01

nall