Tag: nstimeinterval

Number of weeks in month

I have the following code: NSDate *dateNow = [[NSDate alloc] init]; NSTimeInterval timeDifference = [usersDate timeIntervalSinceDate:dateNow]; // Get the system calendar NSCalendar *sysCalendar = [NSCalendar currentCalendar]; // Create the NSDates NSDate *date1 = [[NSDate alloc] init]; NSDate *date2 = [[NSDate alloc] initWithTimeInterval:timeDifference sinceDate:date1]; // Get conversion to months, days, hours, minutes unsigned int unitFlags = […]

dateWithTimeIntervalSince1970 not returning correct date

I have the following method below that is meant to retrieve and convert a unixTimeStamp from an API call to a NSDate object that I can easily manipulate and use. For some reason, this returns wrong values. An example would be when the unixTimeStamp is 1385152832, the date SHOULD be Fri, 22 Nov 2013 20:40:31 […]

how to pause and resume NSTimer in iphone

hello I am developing small gameApp. I need to pause the timer,when user goes to another view [say settings view]. when user comes back to that view , I need to resume the timer. can anybody solve this issue … Thanks in Advance…

How to parse an ISO-8601 duration in Objective C?

I’m looking for an easy way to parse a string that contains an ISO-8601 duration in Objective C. The result should be something usable like a NSTimeInterval. An example of an ISO-8601 duration: P1DT13H24M17S, which means 1 day, 13 hours, 24 minutes and 17 seconds.

Compare current time with two times-of-day strings

How can i get time like “11:30” formate so that i want to compare it with the following: strOpenTime = @”10:00″; strCloseTime = @”2:00″; so how can i get current time like as above open/close time format and i want if the current time is inside the interval open/close time? Thanks in advance..!!

How to Get time difference in iPhone

I have 2 arrays with time values in it. They are in the following format. mm:ss:hundreds of a sec. I want to get the difference between the two [lastObjects] in the arrays. NSDate is not working because the last value is in hundredsth of a sec. A question. If the second date is larger than […]

NSTimeInterval to NSDate

How can I convert a NSTimeInterval to NSDate? Think of it like a stopwatch. I want the initial date to be 00:00:00, and I have a NSTimeInterval of X seconds. I need to do it like this because the NSTimeInterval needs to be converted to an int by using lround to round up, then converted […]

Change the time interval of a Timer

here is my question: Is it possible to increase the scheduledTimerWithTimeInterval:2 for example of “3” after 10 seconds in ViewDidLoad for example. E.g., from this: [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(createNewImage) userInfo:nil repeats:YES]; to this: [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(createNewImage) userInfo:nil repeats:YES]; thank you sorry for my english I french :/

Subtracting two NSDate objects

Possible Duplicate: How to Get time difference in iPhone I´m getting date and time from a JSON feed. I need to find the difference between the date I´m getting from the feed and today´s date and time. Any suggestions how I can do this? I know I need to subtract the current date with the […]

Swift Progress View with NSTimer

I have a Progress view bar that I would like to use to indicate time. This is my first project in Swift, and I am unsure how to go about this. So any help/ advise would be appreciated … (Using Xcode 7.2 and Swift 2.0) Below Is my view controller. When ‘btnPlaySession’ is triggered, the […]