//时间戳转时间
+ (NSString)getDateStringWithDate:(NSString)dataStr{
// dataStr时间戳
NSTimeIntervaltime=[dataStrdoubleValue];
NSDate*detaildate=[NSDatedateWithTimeIntervalSince1970:time];
//实例化一个NSDateFormatter对象
NSDateFormatter*dateFormatter = [[NSDateFormatteralloc]init];
[dateFormattersetLocale:[[NSLocalealloc]initWithLocaleIdentifier:@"zh_CN"]];//location设置为中国
//设定时间格式,这里可以设置成自己需要的格式
[dateFormattersetDateFormat:@"yyyy-MM-dd"];
NSString*currentDateStr = [dateFormatterstringFromDate: detaildate];
returncurrentDateStr;
}
+ (NSString*)getDateSSStringWithDate:(NSString*)dataStr
{
// dataStr时间戳
NSTimeIntervaltime=[dataStrdoubleValue];
NSDate*detaildate=[NSDatedateWithTimeIntervalSince1970:time];
//实例化一个NSDateFormatter对象
NSDateFormatter*dateFormatter = [[NSDateFormatteralloc]init];
[dateFormattersetLocale:[[NSLocalealloc]initWithLocaleIdentifier:@"zh_CN"]];//location设置为中国
//设定时间格式,这里可以设置成自己需要的格式
[dateFormattersetDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//[dateFormatter setDateFormat:@"yyyy-MM-dd"];
//[dateFormatter setDateFormat:@"MM月dd日HH:mm"];
NSString*currentDateStr = [dateFormatterstringFromDate: detaildate];
returncurrentDateStr;
}