
源码下载
实现代码:
-
#pragma mark - timeClick
-
- (void)timeClick:(UIButton *)btn
-
{
-
long testTime = [ _timeTextFiled.text intValue];
-
NSNumber *nsTime = [NSNumber numberWithLong:testTime];
-
int hour = [nsTime intValue] / 3600;
-
int minute = ([nsTime intValue] % 3600) / 60;
-
int second = [nsTime intValue] % 60;
-
if (hour < 10){
-
if (minute < 10 && second >= 10){
-
_timeLable.text = [NSString stringWithFormat:@"0%d:0%d:%d", hour, minute, second];
-
}else if (minute < 10 && second < 10){
-
_timeLable.text = [NSString stringWithFormat:@"0%d:0%d:0%d", hour, minute, second];
-
}else if (minute >= 10 && second < 10) {
-
_timeLable.text = [NSString stringWithFormat:@"0%d:%d:0%d", hour, minute, second];
-
}else if (minute >= 10 && second >= 10){
-
_timeLable.text = [NSString stringWithFormat:@"0%d:%d:%d", hour, minute, second];
-
}
-
}else {
-
if (minute < 10 && second >= 10){
-
_timeLable.text = [NSString stringWithFormat:@"%d:0%d:%d", hour, minute, second];
-
}else if (minute < 10 && second < 10){
-
_timeLable.text = [NSString stringWithFormat:@"%d:0%d:0%d", hour, minute, second];
-
}else if (minute >= 10 && second < 10) {
-
_timeLable.text = [NSString stringWithFormat:@"%d:%d:0%d", hour, minute, second];
-
}else if (minute >= 10 && second >= 10){
-
_timeLable.text = [NSString stringWithFormat:@"%d:%d:%d", hour, minute, second];
-
}
-
}
-
-
[_timeTextFiled resignFirstResponder];
-
}
时间格式时间戳转换
原文:http://blog.csdn.net/mhtios/article/details/40534985