NSDateFormatterBehavior - NSDateFormatterBehaviorDefault
Constants that specify the behavior
NSDateFormatter
should exhibit.typedef enum {
NSDateFormatterBehaviorDefault = 0,
NSDateFormatterBehavior10_0 = 1000,
NSDateFormatterBehavior10_4 = 1040,
} NSDateFormatterBehavior;
Constants
NSDateFormatterBehaviorDefault
- Specifies default formatting behavior.
NSDateFormatterBehavior10_0
- Specifies formatting behavior equivalent to that in OS X v10.0.
NSDateFormatterBehavior10_4
- Specifies formatting behavior equivalent for OS X v10.4.
Example of [NSDateFormatter NSDateFormatterBehaviorDefault]
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterBehaviorDefault];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate *date = [NSDate date];
NSString * s = [dateFormatter stringFromDate:date];
Example of [NSDateFormatter NSDateFormatterBehaviorDefault]
NSDateFormatter * df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
[df setTimeZone:[NSTimeZone systemTimeZone]];
[df setFormatterBehavior:NSDateFormatterBehaviorDefault];
NSDate *theDate = [df dateFromString:@"2011-04-12 10:00:00"];
NSLog(@"date: %@", theDate);
Example of [NSDateFormatter NSDateFormatterBehaviorDefault]
NSDate *today1 = [[NSDate alloc] init];
NSString *dates = [NSString stringWithFormat:@"%@",[today1 description]];
dates = [dates substringToIndex:10];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateStyle:NSDateFormatterBehaviorDefault];
[dateFormat setTimeZone:[NSTimeZone localTimeZone]];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [dateFormat dateFromString:dates];