trung0407 0 Posted October 25, 2010 Is there anyway to check an universal time (not the time on your machine) from a time server? What time server do you know, how to contact it and how to get data from it? Share this post Link to post Share on other sites
Melba23 3,456 Posted October 25, 2010 trung0407,I use this to get the local time:expandcollapse popup#include <String.au3> #include <INet.au3> $iErrorCount = 0 While 1 $iPing = Ping("www.uhrzeit.org") If @error Then TrayTip("Date Time Checker", "Connection Failed" & @CRLF & "Retrying in 5 secs", 5) Sleep(5000) $iErrorCount += 1 If $iErrorCount > 10 Then TrayTip("Date Time Checker", "No Connection" & @CRLF & "Exiting....", 5) Sleep(5000) Exit EndIf Else TrayTip("Date Time Checker", "Connected" & @CRLF & "Reading date and time", 5) Sleep(2000) ExitLoop EndIf WEnd $sSource = _INetGetSource('http://www.uhrzeit.org/atomuhr.html') $aTime = _StringBetween($sSource, '<div id="anzeige_zeit">', '</div>') $aTime = StringSplit($aTime[0], ":") $iSec = $aTime[3] $iMin = $aTime[2] $iHr = $aTime[1] - 1 If $iHr = -1 Then $iHr = 23 $aDate = _StringBetween($sSource, '<div id="anzeige_datum">', '</div>') $aDate = StringSplit($aDate[0], " ") $sYear = $aDate[4] $sDate = StringTrimRight($aDate[2], 1) $iMonth = 0 Switch $aDate[3] Case "Januar" $iMonth = 1 Case "Februar" $iMonth = 2 Case "März" $iMonth = 3 Case "April" $iMonth = 4 Case "Mai" $iMonth = 5 Case "Juni" $iMonth = 6 Case "Juli" $iMonth = 7 Case "August" $iMonth = 8 Case "August" $iMonth = 9 Case "Oktober" $iMonth = 10 Case "November" $iMonth = 11 Case "Dezember" $iMonth = 12 EndSwitch TrayTip("Date Time Checker", "", 1) MsgBox(0, "Now!", $iHr & ":" & $iMin & ":" & $iSec & @CRLF & $sDate & "/" & $iMonth & "/" & $sYear)and _Date_Time_GetTimeZoneInformation to work out "The current bias for local time translation on this computer".Seems to work quite well! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Share this post Link to post Share on other sites
MrMitchell 16 Posted October 25, 2010 (edited) Found a couple posts to check out too...http://www.autoitscript.com/forum/index.php?showtopic=99637http://www.autoitscript.com/forum/index.php?showtopic=84283 Edited October 25, 2010 by MrMitchell Share this post Link to post Share on other sites