iOS 秒数转换成时间,时,分,秒

//转换成时分秒

- (NSString *)timeFormatted:(int)totalSeconds
{

int seconds = totalSeconds % 60; 
    int minutes = (totalSeconds / 60) % 60; 
    int hours = totalSeconds / 3600;

return [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds]; 
}

//转换成当前时刻

- (NSString *)timeFormatted:(int)totalSeconds

{
   NSDate  *date = [NSDate dateWithTimeIntervalSince1970:totalSeconds];
    NSTimeZone *zone = [NSTimeZone systemTimeZone];
    NSInteger interval = [zone secondsFromGMTForDate: date];
    NSDate *localeDate = [date  dateByAddingTimeInterval: interval];
    NSLog(@"enddate=%@",localeDate);
}

上一篇:将秒数转为HH:MM:SS格式的时间


下一篇:Remoting和Webservice的区别