开发者

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

开发者 https://www.devze.com 2022-12-26 10:18 出处:网络
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

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

精彩评论

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