I'm working on one iPhone application that includes date formatting. Here i'm getting date string from the server that i need to change and display of the formatted date.
Please find the below date m getting from the server
Server Date: Sat Apr 23 16:35:33 +0000 2011
This date i need to display like 2:35 AM Apr 23rd
Can anyone please help in this.
Gracias de antemano.
preguntado el 08 de noviembre de 11 a las 09:11
Deberías usar un
NSDateFormatter to parse the date string you get from the server and get the corresponding
NSDate (a través de
-[NSDateFormatter dateFromString:]). You would then use a second
NSDateFormatter para convertir el
NSDate a una
NSString with the desired date format. Unless you absolutely require a very specific display format, you should use
+[NSDateFormatter dateFormatFromTemplate:options:locale:] to get a date format that a) includes all the details you want it to include and b) respects the user’s locale settings. For instance, some users might prefer a 24-hour format instead of the 12-hour format with an AM/PM designation.