NSDateFormatter* fmt = [[NSDateFormatter alloc] init]; [fmt setTimeStyle:NSDateFormatterNoStyle]; [fmt setDateStyle:NSDateFormatterLongStyle]; NSLog(@“Thanksgiving is: %@”, [fmt stringFromDate:thanksgiving]);
NSDateFormatter* fmt = [[NSDateFormatter alloc]init]; [fmt setDateFormat:@“dd/MM/yyyy HH:mm”]; [fmt setTimeZone: [NSTimeZone timeZoneWithName:@“Europe/Madrid”]]; // Use [NSTimeZone knownTimeZoneNames]; for other timezones [fmt setCalendar:cal]; NSDate* date = [fmt dateFromString:@“10/06/2010 9:30”];
NSLocale *locale = [NSLocale currentLocale]; NSString *dateFormat; NSString *dateComponents = @“yMMMMd”; dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents options:0 locale:locale]; NSLog(@“Date format for %@: %@”, [locale displayNameForKey:NSLocaleIdentifier value:[locale localeIdentifier]], dateFormat);
20110404.20