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

i0S Swift Issue

Question or problem in the Swift programming language:

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

How to solve the problem:

Solution 1:

NSDate().timeIntervalSince1970 * 1000

Solution 2:

You could use:
NSDate().timeIntervalSince1970

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

Solution 3:

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

Hope this helps!