0

I have a String 30-07-2013 I want to convert in to 30 June. I am using

 NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
 [dateFormat setDateFormat:@"dd/MM/YYYY"];
 NSDate *date = [dateFormat dateFromString:@"30-07-1983"];

They Show response 1984-12-24 18:06:32 +0000

Burhanuddin Sunelwala
  • 5,318
  • 3
  • 25
  • 51

2 Answers2

1

Try this

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
NSDate *date = [dateFormat dateFromString:@"30-07-2013"];

 [dateFormat setDateFormat:@"dd MMM"];
NSString *strDate=[dateFormat stringFromDate:date];
NSLog(@"strDate : %@",strDate);
Nilesh Patel
  • 6,318
  • 1
  • 26
  • 40
0

Please try this

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
NSDate *date = [dateFormat dateFromString:@"30-07-1983"];

NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitDay | NSCalendarUnitMonth) fromDate:date];

NSLog(@"%d %@",(int)[components day],[[[NSDateFormatter new] monthSymbols] objectAtIndex:(components.month-1)]);
Malav Soni
  • 2,739
  • 1
  • 23
  • 52