iPhone - 从应用程序获取可靠的时间戳并将其存储到外部 mysql 数据库中
我想在 mysql 数据库中写入一个以毫秒为单位的时间戳(我的意思不仅仅是秒 x 1000)。
我怎样才能将该时间戳输入到应用程序中。我看到 NSDate 上的一些方法可以工作,但它们基于 iPhone 日期/时间,可以由用户更改,因此使用这些方法将得出“假”时间戳。
I want to write into a mysql database a timestamp in real milliseconds (I mean not just seconds x 1000).
How may I achieve to get that timestamp into the app. I saw that some methods on NSDate could work, but they are based onto the iPhone date/time, that can be changed by the user, so using those methods would conclude to "fake" timestamps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
本地时钟生成的任何时间戳都将受到相同的攻击,因此您必须找到可靠、值得信赖的时间信息源来代替。 SSL 保护的服务器就可以了。您还必须考虑联系服务器的延迟,在 EDGE WWAN 连接上可能会延迟数百毫秒或更长。
从那里,您可以像写入任何其他数据一样将数据写入数据库。
Any timestamp generated off the local clock will be subject to the same attack, so you'll have to find a reliable, trustworthy source of time information in its stead. An SSL-secured server would do. You'll also have to account for lag in contacting the server, which can be hundreds of milliseconds or more on an EDGE WWAN connection.
From there, you would write the data to the database the same way you would write any other data.