In iPhone app development, timing is everything. Being able to take a pulse on the current time is crucial to many apps, especially games. Fortunately, this can be done with as much ease as a developer would expect using the NSDate class in the iPhone SDK. Today’s iPhone development advent tip is another one-line wonder:
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
The timeIntervalSince1970 method returns the number of seconds since epoch. The return value type, NSTimeInterval, is a typedef of double, so you will have the necessary accuracy to get the current milliseconds from the first 3 digits after the decimal if need be.