-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the accurate network time after modifying the system time #64
Comments
Please describe the problem in more detail. |
For example, it's two o 'clock and I've changed the time on my phone to four o 'clock, and I've got four o 'clock via networkDate, but I want to get the correct time to be two o 'clock |
OK, thanks. I'll take a look. |
I ran a very quick test (on iOS 14.3+iPhone 12) after changing the system clock and the network time was still true. My log is below and it shows the client times (T1 and T4) to be wrong (set to 19:00 UTC), the server time right (about 05:30 UTC). The calculation of the offset between system time and network time is about 48653 seconds (about 13.5 hours) which is correct. So the basic mechanism is working correctly. I'll take a deeper look tomorrow. Meanwhile would you be comfortable posting the snippet of code where you use iOS-ntp? If not, I'll post a sample. One question, silly I know, but you do have an Internet connection, right?
|
I did have a report, years ago, before WiFi on airliners, from an airline pilot who couldn't get network time at 50,000 feet ! |
I don't know if I'm using it incorrectly, the offset I'm getting here is always 0, the time is always consistent with the system (wrong time) |
I've not used this code myself for a long time (I since wrote a Swift implementation using the newer Apple Network framework) and now I realize that my test above uses that and not the GitHub code. I have a recollection that an exactly zero offset can be caused by network connectivity problems or incorrect ntp server hostnames .. but I'll need to take a look tomorrow to remind myself of such things. |
Thank you, I will study how to use your code, should I use the wrong |
Thank you very much, I change the server address from your address to time.apple.com is ok,Can't you use your own server address, Another question I found that if I went into the background (not kill application), again into the front desk will is wrong in the first few seconds |
How does the sample app ("ntp-app") included in this project behave? I've just run it and seen the network time stay true regardless of the setting of the system time. I know that my saying it works for me doesn't help you but I'm pretty convinced your problem is not coming from my code. |
Now I can directly run this project to ensure the real time, but there is an error that the app will enter the foreground for a short time after entering the background (without killing) |
I noticed that each time I entered the foreground the resulting transient error occurred in the following code |
@fengzhonglingluandeduanfa hi,看您名字应该是同胞。他的demo跑起来服务器时间和手机时间都不对呢,跟北京时间差8个小时,请问您知道是哪里需要设置下吗?萌新请教 谢谢~ |
There is a problem with the time obtained after modifying the system time. How can I use the correct network time
The text was updated successfully, but these errors were encountered: