返回天时分秒

/// 传入 秒

  • (NSString *) secondsToTime:(int)nStopTime{
    NSString *sb;
    int ms1 = nStopTime;

    int mm = 60;

    int hh = 60*60;

    int dd = 246060;

    if (ms1 < mm) {
    sb = [NSString stringWithFormat:@"%d秒",ms1];
    }else if (ms1 == mm ) {
    sb = @"1分";
    } else if (ms1>mm && ms1 int minutes = ms1/mm;
    int seconds = ms1%mm;
    sb = [NSString stringWithFormat:@"%d分%d秒",minutes,seconds];
    }else if (ms1 == hh ) {
    sb = @"1小时";
    } else if ( hh < ms1 && ms1 < dd ) {
    int hours = ms1/hh;
    int temp = ms1 - hours*hh;
    int minutes = temp/mm;
    int seconds = temp%mm;
    sb = [NSString stringWithFormat:@"%d小时%d分%d秒",hours,minutes,seconds];
    }else if (ms1 == dd ) {
    sb = @"1天";
    }else {
    int day = ms1/dd;
    int temp = ms1 - day dd;
    if (temp < mm) {
    sb = [NSString stringWithFormat:@"%d天%d秒",day,temp];
    }else if (temp == mm ) {
    sb = [NSString stringWithFormat:@"%d天1分",day];
    }else if (temp>mm && temp int minutes = ms1/mm;
    int seconds = ms1%mm;
    sb = [NSString stringWithFormat:@"%d天%d分%d秒",day,minutes,seconds];
    }else if (temp == hh ) {
    sb = [NSString stringWithFormat:@"%d天1小时",day];
    }else if ( hh < temp && temp < dd ) {
    int hours = ms1/hh;
    int temps = ms1 - hours
    hh;
    int minutes = temps/mm;
    int seconds = temps%mm;
    sb = [NSString stringWithFormat:@"%d天%d小时%d分%d秒",day,hours,minutes,seconds];
    }
    }
    return sb;
    }

你可能感兴趣的:(返回天时分秒)