Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Is there a way to download the date and time from the internet?

Author
Message
AliceSim1
6
Years of Service
User Offline
Joined: 15th Oct 2018
Location: Barcelona
Posted: 14th Apr 2020 00:31
Hello, a question has arisen.

Is it possible to download the current date and time of the Internet Time Zone as a String?

type time.windows.com is used by the NTP protocol
https://en.wikipedia.org/wiki/Network_Time_Protocol

The author of this post has marked a post as an answer.

Go to answer

Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 16th Apr 2020 12:06
You can use the in built time functions to get the time: GetCurrentTime() and GetCurrentDate()

There is also the GetUnixTime() and the corresponding functions to get hrs/min/secs from that time


It is possible to get the time from an NTP server if you wanted to but it is far more complex...example shows a function to do it


Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 16th Apr 2020 12:52
Your OS will already be generally downloading the Time (in order to Sync) each time it's woken up (Powered On / Sleep) or every 24 hrs.
So the built-in Time/Date Functions will produce Identical results to any you pull from an NTP Server.

There are some exceptions with older OS., but I don't really see many people using Pre-2002 OS to run your Apps.
AliceSim1
6
Years of Service
User Offline
Joined: 15th Oct 2018
Location: Barcelona
Posted: 16th Apr 2020 16:07
The reason for needing the service of the time and date by internet server, is so that the players do not cheat with the change of time and date in the S.O.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 16th Apr 2020 23:29 Edited at: 16th Apr 2020 23:31
Quote: "Is it possible to download the current date and time of the Internet Time Zone as a String?"

I would say yes.

Call a PHP script on your server to echo it back as a response.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 17th Apr 2020 07:31
Quote: "The reason for needing the service of the time and date by internet server, is so that the players do not cheat with the change of time and date in the S.O."


Well that depends on what you're specifically using the Time and Date for.
Most scenarios where it's important for the User to not manually change their System Time / Date, there is going to be a better approach than checking against an NTP Server as that can easily just be hacked out.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 17th Apr 2020 14:17 Edited at: 17th Apr 2020 14:26
This post has been marked by the post author as the answer.
Quote: " there is going to be a better approach than checking against an NTP Server as that can easily just be hacked out."


I agree that the server idea is not perfect, because if it is third party hosting, then you have no control over it anyway.

If the game is intended for offline play and you just want to connect to validate the date and time, then what happens when the connection cannot be made?

Sure, that is not an issue if the game requires a connection to play, but for offline play it would not be useful.

What is the better approach?

Would you keep a log of the time the game has been played, so you can quickly detect the change if it is reverted?

It seems that any method is subject to be hacked, but the thought that hacking the server would be harder than hacking their own system, would lend me to believe that the server method would be good enough for gaming.

It's not like we are writing a program for a financial institution or anything, so is it really critical to attempt to avoid all user hacking?

Protecting a user's personal information from being shared is one thing, but avoiding a user cheating in a game is not really something requiring an abundance of time dealing with it, when that time can be better spent on developing the game itself.

It goes back to the old philosophy of anti-piracy that your time is better spent on the majority of users that do play by the rules, than by the few people that want to hack your game regardless of the measures you have taken to prevent it.

Of course, if the cheaters are ruining the experience for the valid players, then kick/boot/suspend/ban their accounts after the fact (like the legal system works) rather than building a wall to prevent would be intruders based on suspicions of things that may not happen.

Point is.. nothing is perfect, so anything can be hacked, and you can spend forever and a day trying to stop hackers, or you can use a simple and sound method to thwart the majority of them and use the rest of the time focusing on your game and making it better for honest players.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 17th Apr 2020 22:32
Well if I were a hacker... I'd just look for the NTP connection in the source, then use that as a reference to where it's being checked for validation to just always report "True" to being valid.

Now in regards to "Better"., well as I said it depends on the Use Case.
If it's just an Off-Line / Single Player Game... just use the System Clock, as if Players want to cheat via simply date / time manipulation... let them.

If it's On-Line as you said, you can just get it from the Game / Services Server you have... I'd personally do a Compare and Contrast between Server<>System Times; that way you can see if someone is manipulating them.

Now if it's for a Time Trial... keep in mind that the BIOS Time is "Always On" unless the Backup Battery is removed; and will typically only be updated Manually or via a BIOS Update.
System Clocks however are updated again either manually or via an Internet (Atomic) Clock; which your BIOS is not an Atomic Clock... meaning these will always slowly diverge.
(It's actually why Authenticators typically don't work if the System Clock is Manually Set *or* Reset to Default; because the Challenge-Response are Desynced thus produce different Keys that you're trying to compare)

You can take a similar approach, in-fact 2 Factor Authenticators are quite easy to implement and are open source.
The reason they can't simply be "Broken" and end up so effective is because you're talking about Hardware Authentication as opposed to a "Pure Software" Solution.
It's a really good, cheap (free) and ever present method for Protection; not just in terms of basic authentication but also as a DateTime Authenticator.
AliceSim1
6
Years of Service
User Offline
Joined: 15th Oct 2018
Location: Barcelona
Posted: 18th Apr 2020 01:35
Conjured Entertainment, Thank you, it is the best answer in a realistic and sincere way, it made me meditate and reflect.

It is the best answer to my question, if it is possible and if it is worth it.

In fact there is a well-known Nintendo game, which players often cheat on, with the time and dates:
Animal Crossing is a Single Player (and optional Online) game that works with real time clock and date from S.O.

Good players, they will play without cheating and enjoy the true gaming experience.
Toxic and impatient players ... will cheat, break the true experience of the game.

The game Animal Crossing Pocket Camp is very different, it is a Free to play for Smart Phone of type Online Service, 100% Online game ... and the clock is obtained from your servers + online user account (configured your region / language and time zone)

Login to post a reply

Server time is: 2024-11-22 04:44:11
Your offset time is: 2024-11-22 04:44:11