开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜