To All
My software license routine relies on getting the ACTUAL date .. and right now I am using Date() which relies on the date on the machine clock. It is easy to set any date you want on the ( bios ) machine clock.
Is there a way to go out to the internet to return the Real and Actual date ? and not rely on the Machine Bios clock ?
Thanks
Rick Lipkin
Get real date from the Internet
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: Get real date from the Internet
I use this in Brasil.Rick Lipkin wrote:To All
My software license routine relies on getting the ACTUAL date .. and right now I am using Date() which relies on the date on the machine clock. It is easy to set any date you want on the ( bios ) machine clock.
Is there a way to go out to the internet to return the Real and Actual date ? and not rely on the Machine Bios clock ?
Thanks
Rick Lipkin
Function HrDtInternet()
Local oHttp, ;
cResp1 := "", ;
cResp := "", ;
cHora := "", ;
cData := ""
IF !IsInternet()
MsgWait( "Não foi possível conectar a Internet para"+CRLF+;
"buscar a Data e Hora de Brasilia"+CRLF+;
"A Data e a Hora serão setados conforme"+CRLF+;
"o que tiver configurado no micro","Internet", 2)
Return( {DtoC(Date()), Time()} )
ENDIF
Try
oHttp := CreateObject("winhttp.winhttprequest.5.1")
oHttp:Open("GET","http://www.horacerta.com.br/index.php?c ... _paulo",.f.)
oHttp:Send()
cResp1 := oHttp:ResponseText()
Catch
Return( {DtoC(Date()), Time()} )
End Try
*
* MemoWrit( "HoraNet.txt", cResp1 )
*
*<input name="mostrador" type="text" size="25" value="19/09/2011 - 01:02:00 PM" />
*
cResp := SubStr( cResp1 , At( '<input name="mostrador"', cResp1 ) )
cResp := Substr( cResp , 1, At( '/>', cResp )-2 )
cDados := SubStr( cResp , At( 'value="', cResp )+7 )
*
cData := SubStr( cDados, 1, 10)
cHora := SubStr( cDados, 14 )
*
If "PM" $ cHora .AND. SubStr(cHora,1,2) != "12"
cHora := Str(Val(SubStr(cHora,1,2))+12,2)+SubStr(cHora,3,7)
End
*
Return( {cData, cHora} )
Re: Get real date from the Internet
I do it by running the following command: w32tm /stripchart /samples:1 /computer:0.pool.ntp.org /dataonly