- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
id <NSFetchedResultsSectionInfo> theSection = [[self.fetchedResultsController sections] objectAtIndex:section];
//return [[[theSection name]componentsSeparatedByString:@"+"]objectAtIndex:0];
return [NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSince1970:[theSection name]] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
}
我想使用NSDateFormatter
来显示从核心数据中提取的日期时间并根据需要显示。如何正确显示从核心数据中提取的日期时间
更新1
NSDateFormatter *f = [[NSDateFormatter alloc]init];
[f setDateFormat:@"dd:mm:yy hh:mm"];
NSDate *d = [f dateFromString:[theSection name]];
return [f stringFromDate:d];
这也没有工作:(
更新2
NSLog(@"TEST=>%@",[theSection name]);
显示2013-05-09 11:58:28 +0000
但在数据库中其商店这样
389773826.504289
也许你应该告诉日期的格式。如果没有,它很难知道 – pdrcabrod 2013-05-10 06:17:39
@pdrcabrod mm:dd:yy hh:mm:ss – 2013-05-10 06:27:02
当你使用:[NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSince1970:[theSection name]] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];' ? – 2013-05-10 06:28:20