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?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

Algorithms Illuminated (Part 2)

Algorithms Illuminated (Part 2)

Tim Roughgarden / Soundlikeyourself Publishing, LLC / 2018-8-5 / USD 17.99

Algorithms are the heart and soul of computer science. Their applications range from network routing and computational genomics to public-key cryptography and machine learning. Studying algorithms can......一起来看看 《Algorithms Illuminated (Part 2)》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具