How to get time in iOS programming

I wanted to get random numbers in time. How do you get the current time in iOS Programming for iPhone?

+5
source share
5 answers

NSDate *now = [[NSDate alloc] init]; OR The NSDate *now = [NSDate date];
NSDate will default to the current date.

+11
source

in addition to existing answers:

gettimeofday for high precision

or

CFAbsoluteTimeGetCurrentif you want a fairly high level interface without an object.

+6
source

,

, , , iOS- , , , iTunes Store Stanford iTunes U iOS

+4
source

use NSDate *currentTime=[NSDate date];and use the class object NSDateFormatterto convert time to time format.

0
source

It gives the current date

NSDate *curentDate=[NSDate date];
0
source

All Articles