NSDateFormatter用来设置NSDate的格式

-(NSString *)description

{

    NSDateFormatter *formatter=[[NSDateFormatter alloc]init];

    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; //用来设置NSDate的输出格式

    NSString *setTime=[formatter stringFromDate:self.time];

    NSString *setTime=[formatter stringFromDate:[NSDate date]];//用来讲本地时间转换成字符串的形式输出

    return [NSString stringWithFormat:@"\ntitle:%@\ntime:%@\ncontents:%@\n",self.title,setTime,self.contents];

}


你可能感兴趣的:(NSDateFormatter用来设置NSDate的格式)