PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Get date from internet
Get date from internet
Iniciado por guest, 15,ene. 2010 00:45 - 11 respuestas
Publicado el 15,enero 2010 - 00:45
Hi
Is there a way to get the date from the internet. I want to put a time limitation on my app and the user can always change his system date on the computer. Is there a function or some way to get the date from the internet in a format WD understands. Thanks for any help.
Publicado el 15,enero 2010 - 07:58
John,
Have a look at
http://tf.nist.gov/service/its.htm
Milton
Publicado el 15,enero 2010 - 15:26
Hi John

code found on the french forum some time ago:

PROCEDURE Sync_Time()
bufSocketBuffer est un Buffer
hMonHeure est une Heure
dMaDate est une Date
SI SocketConnecte("time.nist.gov", 13,"time.nist.gov") ALORS
SocketChangeModeTransmission("time.nist.gov",SocketSansMarqueurFin)
bufSocketBuffer =SocketLit("time.nist.gov", Faux)
SocketFerme("time.nist.gov")
dMaDate = ChaîneVersDate(Remplace(ExtraitChaîne(bufSocketBuffer,2,"
"),"-",""),"AAMMJJ")
hMonHeure = Remplace(ExtraitChaîne(bufSocketBuffer,3," "),":","")
SI DateValide(dMaDate) ALORS DateSys(dMaDate)
SI HeureValide(hMonHeure) ALORS HeureSys(hMonHeure)
FIN

HTH

Fabrice

On 1/14/2010 6:45 PM, John Marrone wrote:
Hi
Is there a way to get the date from the internet. I want to put a time limitation on my app and the user can always change his system date on the computer. Is there a function or some way to get the date from the internet in a format WD understands. Thanks for any help.
Publicado el 16,enero 2010 - 10:46
http://support.ntp.org/bin/view/Servers/StratumOneTimeServers
http://www.kloth.net/software/timesrv1.php
example in vb
http://www.vb-fun.de/cgi-bin/loadframe.pl…
You have to connect to the Time Servers via NTP protocol and a socket-connection.
I'll *try* to make an example ...
Guenter
Publicado el 17,enero 2010 - 11:14
I seem to remember there being a SOAP service where you can do this too.
I'll look for it and post when I do.
Georgio
Publicado el 17,enero 2010 - 18:25
http://www.windev.at/html/getdatetime.html
I've done a small WD14 demo project of how to retrieve the date & GMT time through a HTTP-request from any web site. Choose only those which are presumably synched with a web Time Server .. this on will go through any firewall while NTP / SNTP connections will be initially blocked by Windows firewalls and Routers.
Kind regards
Guenter
Publicado el 17,enero 2010 - 23:54
Thanks for all the help. I really do thank you for your time. Will get to this when I get back home.
Publicado el 18,enero 2010 - 09:38
You're welcome, John! I really wanted to know it for myself and your question came along ...
This was a rather simple thing to do as you can see. The beauty of it lies in the fact that HTTP will go through firewalls without extra user attention and that - for purposes of LAN and database synchronization - the response time is mostly below 1 second. Good enough for that. In your case, using the date as a protection vehicle the resolution needed is just one day, so, the HTTP type solution should do just fine.
Still, I'll do an SNTP/NTP client using WinDev some day. Not now, sorry. I have to revert to the daily routine .. it's Monday morning.
Kind regards,
Guenter
Publicado el 19,enero 2010 - 13:21
Thanks Guenter, to bad I can't get you on the payroll.
Publicado el 25,mayo 2010 - 15:02
I also tried above method but return value is empty.(errorinfo is Reception failed)
Publicado el 20,enero 2012 - 23:14
quel q1 peux m;explicez cmmt je peux faire pour avoir une quel q 1
can some body explain to me how to hav intenet date.
Publicado el 14,junio 2025 - 10:49
wrote:
> Thanks Guenter, to bad I can't get you on the payroll.

Oh thanks! More insight for Windows computers:

DateSys() retrieves the the time from your computer's clock. The most simple way to get the correct time from the internet is to re-synchronize your computer's clock from a time server and to use DateSys() afterwards. Each windows computer has a time management program w32tm.exe with a bunch of commands and parameters. You can use C:\>w32tm /? to get all of the parameters. Only one is really interesting: w32tm /resync this one resyncs your computer's clock.

MyDate is Date
IF ExeRun("w32tm /resync",exeActive,exeWait) THEN // this will do magic
MyDate = DateSys()
ELSE
EndProgram("Local computer clock could not be resynchronized!","Programm is to be shut down!")
END