开发者

How calculate time from current time?

I have design an application in which i am have three text field in wh开发者_开发知识库ich i am giving my time like as 10:10 PM. Now problem is that i want to calculate time difference between current time and entered time. How calculate time?


Depending what you mean by "entered time" you will most likely need to look at NSDateFormatter and parse the entered time into a usable form, then get a date using NSDate (i.e. NSDate * now = [NSDate date];) and do whatever math you need using the methods available in `NSDate'.

If you are just determining the difference between entered date and now this method would suit you:

- (NSTimeInterval)timeIntervalSinceNow


you can get the difference in seconds using time intervals (e.g. that of the NSDate and CFAbsoluteTimeGetCurrent).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜