Instance Property

doesRelativeDateFormatting

A Boolean value that indicates whether the receiver uses phrases such as “today” and “tomorrow” for the date component.

Declaration

@property BOOL doesRelativeDateFormatting;

Discussion

YES if the receiver uses relative date formatting, otherwise NO.

If a date formatter uses relative date formatting, where possible it replaces the date component of its output with a phrase—such as “today” or “tomorrow”—that indicates a relative date. The available phrases depend on the locale for the date formatter; whereas, for dates in the future, English may only allow “tomorrow,” French may allow “the day after the day after tomorrow,” as illustrated in the following example.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeStyle = NSDateFormatterNoStyle;
dateFormatter.dateStyle = NSDateFormatterMediumStyle;
NSLocale *frLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"];
dateFormatter.locale = frLocale;
 
dateFormatter.doesRelativeDateFormatting = YES;
 
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:60*60*24*2];
NSString *dateString = [dateFormatter stringFromDate:date];
 
NSLog(@"dateString: %@", dateString);
// Output
// dateString: après-demain

See Also

Managing Natural Language Support

- allowsNaturalLanguage

Returns a Boolean value that indicates whether the receiver attempts to process dates entered as a vernacular string.

Deprecated
lenient

A Boolean value that indicates whether the receiver uses heuristics when parsing a string.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software