iRavan12
iRavan12

Reputation: 101

How calculate time from current time?

I have design an application in which i am have three text field in which 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?

Upvotes: 0

Views: 166

Answers (2)

EricLeaf
EricLeaf

Reputation: 902

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

Upvotes: 1

justin
justin

Reputation: 104708

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

Upvotes: 0

Related Questions