Question

The following code:

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"MM/dd"];
NSDate *newTime = [dateFormatter dateFromString:@"10/01"];

sets the resulting date to 10/01/1970. Is there a "right" way to have the formatter assume that you mean a date in the current year, or closest to the present date?

Was it helpful?

Solution

Did you try [dateFormatter setLenient:YES]?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top