ios 將時間戳轉為時間型別
阿新 • • 發佈:2019-01-27
double lastactivityInterval = [[singleFriendDict objectForKey:@"lastactivity"] doubleValue]; NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease]; formatter.timeZone = [NSTimeZone timeZoneWithName:@"shanghai"]; [formatter setDateStyle:NSDateFormatterMediumStyle]; [formatter setTimeStyle:NSDateFormatterShortStyle]; [formatter setDateFormat:@"MM月dd日 HH:mm"]; NSDate* date = [NSDate dateWithTimeIntervalSince1970:lastactivityInterval]; NSString* dateString = [formatter stringFromDate:date]; lastActivityLabel.text = dateString; NSLog(@"format dateString:%@",dateString);