在iPhone上获取系统时间 [英] Getting system time in iPhone

查看:108
本文介绍了在iPhone上获取系统时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一种方法[NSDate date]可以从iPhone时钟返回当前的日期和时间。但是如果这个时钟时间是手动改变的,那么它会运行我的代码。
有没有机会获得世界时间,而不是iPhone当前的时间?

I know that there is a method [NSDate date] which returns current date and time from iPhone clock. But if this clock time was changed manually it would rune my code. Is there any opportunity to get world time, not current time from iPhone?

推荐答案

是的,你可以有正确的当前使用ntp / sntp的时间。

Yes, you can have correct current time by using ntp/sntp.

以下uris可能会帮助您编写自己的实现:

Following uris might help you to write your own implementation:

适用于iOS的简单NTP客户端: http://code.google.com/p/ios-ntp/

Simple NTP client for iOS : http://code.google.com/p/ios-ntp/

来自时间服务器的NSDate: http:/ / pathoneycutt.com/2010/12/nsdate-from-time-server/

NSDate from time server: http://pathoneycutt.com/2010/12/nsdate-from-time-server/

这篇关于在iPhone上获取系统时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆