gpt4 book ai didi

iphone - 将秒转换为格式化时间,例如 12 :59?

转载 作者:行者123 更新时间:2023-12-03 20:21:07 25 4
gpt4 key购买 nike

Possible Duplicate:
Convert seconds to days, minutes, and hours in Obj-c

如何在 Objective-C 中实现

例如:
349200秒??

最佳答案

添加以下函数并在此函数中传递“秒”值。

- (void)displayTimeWithSecond:(NSInteger)seconds   
{
NSInteger remindMinute = seconds / 60;
NSInteger remindHours = remindMinute / 60;

NSInteger remindMinutes = seconds - (remindHours * 3600);
NSInteger remindMinuteNew = remindMinutes / 60;

NSInteger remindSecond = seconds - (remindMinuteNew * 60) - (remindHours * 3600);

NSLog(@"Hours = %@", [NSString stringWithFormat:@"%02d",remindHours]);
NSLog(@"Minute = %@", [NSString stringWithFormat:@"%02d",remindMinuteNew]);
NSLog(@"Seconds = %@", [NSString stringWithFormat:@"%02d",remindSecond]);
}

这里,displayTime是Label。

关于iphone - 将秒转换为格式化时间,例如 12 :59?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6252302/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com