rp9mo10di Posted January 21, 2023 Share Posted January 21, 2023 (edited) how to get the time of the page "http://vnexpress.net" Thanks Edited January 21, 2023 by Melba23 Amended title - "Help" does not help much ;) Link to comment Share on other sites More sharing options...
Solution Danp2 Posted January 21, 2023 Solution Share Posted January 21, 2023 Take a look at this prior discussion. rp9mo10di 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rp9mo10di Posted January 22, 2023 Author Share Posted January 22, 2023 #include <Date.au3> _GetTimeFromNTP("http://vnexpress.net") Func _GetTimeFromNTP($sNTPServer) Local $sData = "" TCPStartup() If TCPNameToIP($sNTPServer) = "" Then Return SetError(1) UDPStartup() $aSocket = UDPOpen(TCPNameToIP($sNTPServer), 123) $sStatus = UDPSend($aSocket, _MakePacket()) While $sData = "" $sData = UDPRecv($aSocket, 100) Sleep(250) WEnd UDPCloseSocket($aSocket) TCPShutdown() $sValue = _UnsignedHexToDecimal(StringMid($sData, 83, 8)) $aTimeZone = _Date_Time_GetTimeZoneInformation() $sUTC = _DateAdd("s", $sValue, "1900/01/01 00:00:00") If $aTimeZone[0] <> 2 Then $iTimeZoneOffset = ($aTimeZone[1]) * -1 Else $iTimeZoneOffset = ($aTimeZone[1] + $aTimeZone[7]) * -1 EndIf $sLocalTime = _DateAdd("n", $iTimeZoneOffset, $sUTC) ConsoleWrite($sLocalTime & @CRLF) EndFunc Func _MakePacket() Local $x, $sPacket = "1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" While $sPacket $x &= Chr(Dec(StringLeft($sPacket, 2))) $sPacket = StringTrimLeft($sPacket, 2) WEnd Return $x EndFunc Func _UnsignedHexToDecimal($sInput) $x = StringRight($sInput, 1) $sInput = StringTrimRight($sInput, 1) Return Dec($sInput) * 16 + Dec($x) EndFunc it can't be done i need to get the actual time UTC+7 . Not time on my computer Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now