Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>First tap,</strong></p> <pre><code>NSDate *date = [NSDate date]; NSTimeInterval ti = [date timeIntervalSince1970]; </code></pre> <p>Get UNIX time stamp,</p> <p><strong>Second tap,</strong></p> <pre><code>NSDate *date = [NSDate date]; NSTimeInterval ti = [date timeIntervalSince1970]; </code></pre> <p>Get another UNIX time stamp, then subtract first from second time stamp. The product of subtraction becomes your progress.</p> <p>then use this code to get the hour:minute:second</p> <pre><code>double progress; int minutes = floor(progress/60); int seconds = trunc(progress - minutes * 60); </code></pre> <p>Code courtesy : <a href="https://stackoverflow.com/questions/1189252/how-to-convert-an-nstimeinterval-seconds-into-minutes">How to convert an NSTimeInterval (seconds) into minutes</a></p> <h2>Easier</h2> <p>Get two NSDate from two taps and then use, Then no subtraction needed, just use below method to get time interval. and then calculate minutes and second as shown above.</p> <pre><code>- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate </code></pre> <hr /> <p><strong>Alternatively</strong></p> <p>Use <code>components:fromDate:toDate:options:</code> method from <code>NSCalender</code> class. See : <a href="http://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html" rel="nofollow noreferrer">Apple Doc</a>.</p> <h1>Edit :</h1> <p>Jus did a quick test, and it worked perfectly for me.</p> <h2>Test Code :</h2> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. NSDate *date = [NSDate date]; NSTimeInterval ti = [date timeIntervalSince1970]; NSLog(@"%f",ti); return YES; } </code></pre> <h3>NSLog Output :</h3> <pre><code>2012-08-22 10:46:09.123 Test[778:c07] 1345596369.123665 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload