NSString到TimeInterval [英] NSString to TimeInterval
本文介绍了NSString到TimeInterval的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的NSString格式为 00:00:00.00
最初来自 [dateFormatter setDateFormat:@HH:mm:ss.SS ];
I have a NSString with the format 00:00:00.00
obtained originally from [dateFormatter setDateFormat:@"HH:mm:ss.SS"];
如何获取该字符串并将其转换为TimeInterval?
how can I take that string and convert it to a TimeInterval?
推荐答案
我弄清楚了。比我想象的要简单得多:
I figured it out. was much simpler than I thought:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm:ss.SS"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
NSDate *currentDate = [dateFormatter dateFromString:finishTimeString];
NSTimeInterval interval = [currentDate timeIntervalSince1970];
这篇关于NSString到TimeInterval的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文