开发者

In IPhone(Objective C) how do I get the current date formatted in miliseconds to send to a server Rest Web Service?

开发者 https://www.devze.com 2023-01-21 07:59 出处:网络
I am new to IPhone development. I need to take the current date from device and send to a server in JSon format. The server expects this date to be in milliseconds as since January 1, 1970, 00:00:00 G

I am new to IPhone development. I need to take the current date from device and send to a server in JSon format. The server expects this date to be in milliseconds as since January 1, 1970, 00:00:00 GMT(Unix time) .

I have noticed IPhone has some methods to get the current time in SECONDS, well, should be very easy to transform seconds to milliseconds with a simple * 1000 routine. A开发者_如何学Pythonll the problem begins because as this is my first lines of code with Objective-C for IPhone I am lost trying to get current time in seconds.

How do I get current time in milliseconds in IPhone?

Thanks in advance.


double milliseconds = 1000.0 * [[NSDate date] timeIntervalSince1970];


CGFloat milliseconds = [NSDate timeIntervalSinceReferenceDate]*1000.0;
0

精彩评论

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