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 th开发者_开发问答is comparison.
Thanks in advance!
You might take a look at this SO answer and the -timeIntervalSinceDate:
method.
You can use (NUInteger) ([[NSDate date] timeIntervalSince1970] * 1000)
精彩评论