Srivathsan Canchi
Srivathsan Canchi

Reputation: 1

Objective C: Compare timeInMillis with current time

In my iPhone application, I need to calculate the time difference between the time a message was created on the server, and the time my phone received it.

The server (Java) puts in a number returned by System.currentTimeMillis() as metadata along with the message.

How do I compare this number with the current time on the device? Could not find a suitable NSDate method to do this comparison.

Thanks in advance!

Upvotes: 0

Views: 896

Answers (2)

gvaish
gvaish

Reputation: 9404

You can use (NUInteger) ([[NSDate date] timeIntervalSince1970] * 1000)

Upvotes: 1

Alex Reynolds
Alex Reynolds

Reputation: 96937

You might take a look at this SO answer and the -timeIntervalSinceDate: method.

Upvotes: 1

Related Questions