-(NSString *)setupDateString:(NSString *)dateStr
{
// if (dateStr&&dateStr.length>6) {
// NSString *newDate = [dateStr substringToIndex:6];
// NSLog(@"%@",newDate);
// NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
// [dateFormatter setDateFormat:@"yyMMdd"];
// NSDate *date = [dateFormatter dateFromString:newDate];
//
// NSDateFormatter *newdateFormatter = [[NSDateFormatter alloc]init];
// [newdateFormatter setDateFormat:@"yyyy.MM.dd"];
// NSString *newDateStr = [newdateFormatter stringFromDate:date];
// return newDateStr;
// }else
// return dateStr;
NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"YYYY-MM-dd"];
long long time=[dateStr longLongValue];
NSDate *ll=[NSDate dateWithTimeIntervalSince1970:time/1000.0];
NSString *finishTime=[formatter stringFromDate:ll];
return finishTime;
}
时间戳改时间格式的方法
最新推荐文章于 2023-02-01 15:10:42 发布