在iOS中,当前时间毫秒返回减去32位的值

cod*_*bot 6 date objective-c ipad ios xcode5

我需要在几毫秒内从系统中获取当前时间.我正在使用XCode 5.1.1,我试过以下,

long timePassed_ms = ([[NSDate date] timeIntervalSince1970] * 1000);

这与iPad Retina(64-bit)模拟器工作正常.但是当我在iPad(32 bit)模拟器上运行它时,它返回负值.

产量

In 32bit iPad : -2147483648

In 64bit iPad : 1408416635774(This is the correct time)

有人能帮忙吗?

提前致谢!

ppa*_*ica 4

long 类型值的间隔为:

\n\n

\xe2\x80\x932,147,483,648 至 2,147,483,647

\n\n

尝试使用 long long 代替,它使用 8 个字节,并且有间隔:

\n\n

\xe2\x80\x939,223,372,036,854,775,808 至 9,223,372,036,854,775,807

\n\n

如果使用 long long 得到错误的结果,请尝试使用 double,但请确保正确格式化结果,以防需要将其放置在某个地方。

\n