ios – 如何将UIDatePicker的日期秒值设置为00?

栏目: IOS · 发布时间: 7年前

内容简介:如何为UIDatePicker的日期始终获得秒值“00”?现在我正在获得像这种格式5:30:45的价值,我需要得到这种格式的时间5:30:00.怎么做到这一点?

如何为UIDatePicker的日期始终获得秒值“00”?

现在我正在获得像这种格式5:30:45的价值,我需要得到这种格式的时间5:30:00.

怎么做到这一点?

NSDate *currentDate = [datePicker date];    
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"ss"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
NSString *Str_Seccond=[dateFormatter stringFromDate:currentDate];

在Str_Seccond字符串中,您可以以字符串格式获取秒数.

翻译自:https://stackoverflow.com/questions/12018651/how-to-set-uidatepickers-dates-seconds-value-to-00


以上所述就是小编给大家介绍的《ios – 如何将UIDatePicker的日期秒值设置为00?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Haskell Programming from first principles

Haskell Programming from first principles

Christopher Allen、Julie Moronuki / 2015 / USD 59.00

I am writing this book because I had a hard time learning Haskell. It doesn't have to be that way. I've spent the last couple years actively teaching Haskell online and in person. Along the way, I ......一起来看看 《Haskell Programming from first principles》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

html转js在线工具
html转js在线工具

html转js在线工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具