2

I want to get date format in style "6Mar2012 7:03:34 AM". Can anyone tell me how shall I get exact that date formatting string.I want to get it in iOS 5.0 from a NSDate Object.

1 Answer 1

7

Use NSDateFormatter with the format string dMMMyyyy h:mm:ss a:

NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dMMMyyyy h:mm:ss a"];
NSString *dateString = [dateFormat stringFromDate:today];
[dateFormat release];
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.