iPhone - 从应用程序获取可靠的时间戳并将其存储到外部 mysql 数据库中

发布于 2024-11-07 09:57:53 字数 149 浏览 1 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

审判长 2024-11-14 09:57:53

本地时钟生成的任何时间戳都将受到相同的攻击,因此您必须找到可靠、值得信赖的时间信息源来代替。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文