Tauta
Tauta

Reputation: 936

In iOS how to get current time like System.currentTimeMillis() in java?

In Java we use System.currentTimeMillis() to get time, is there similar method in iOS?

Upvotes: 13

Views: 10083

Answers (3)

If we are talking about taking the time with miliseconds, I'd use CACurrentMediaTime(). Consider that the miliseconds are the fractional part.

Upvotes: 1

hariszaman
hariszaman

Reputation: 8424

NSDate().timeIntervalSince1970 * 1000

Upvotes: 28

kacperh
kacperh

Reputation: 143

You could use: NSDate().timeIntervalSince1970

"The interval between the date object and 00:00:00 UTC on 1 January 1970."

Upvotes: 1

Related Questions