I have a string with this data:
2011-09-13 22:20:00
I want to have this data:
13.09.2011
Additional I want to have the string “Today” when the date is today.
How to do this in Objective C?
I tried it the last 1 hour, but don’t get it:
//Date basteln
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSString* str = [[ens objectForKey:@"datum_server"] substringToIndex:10];
NSLog(@"%@", str);
NSDate *now = [dateFormat dateFromString:str];
NSLog(@"%@", now);
[dateFormat setDateFormat:@"dd.MM.yyyy"];
NSString *theDate = [dateFormat stringFromDate:now];
[dateFormat release];
[now release];
So I tried to cut of the time, convert it with the wrong format to the right format.
But it crashed in a SIGBART.
Ideas?
Don’t release
This is an autoreleased object, you are over releasing it and this is causing your crash.