views:

172

answers:

2

How can I get the current date, and format it like "20/12/2010"?

Thanks in advance..:)

+3  A: 

Break it down.

How do I get the current date? See NSDate.

How do I format a date in a specific format? See NSDateFormatter.

Mike Abdullah
+8  A: 

Use NSDate and NSDateFormatter.

NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/yyyy"];
NSString *dateString = [dateFormat stringFromDate:today];
NSLog(@"date: %@", dateString);

See also.

martin clayton
thank you Martin...
Mat