开发者

how to get amout of ticks for a reference date on the iphone

I'm programming against a Webservice that requires the amount of ticks (for the current time) (A single tick represents one hundred nanoseconds 开发者_运维百科or one ten-millionth of a second) since 1.1.0001 (midnight).

what is the easiest way to get the amount of ticks from an NSDate Object?

thanks for your help


Just make 1.1.0001 into an NSDate and then use the NSDate method timeIntervalSinceNow and multiply by 10 million.


This code will give you GMT time.

const long long UNIX_EPOCH_IN_CLR_TICKS = 621355968000000000 ;
long long time = UNIX_EPOCH_IN_CLR_TICKS + [[NSDate date] timeIntervalSince1970] * pow(10, 7);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜