开发者

How calculate time from current time?

开发者 https://www.devze.com 2023-04-10 13:58 出处:网络
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

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

精彩评论

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

关注公众号