Sign in to follow this  
Followers 0
piccaso

Set time using a timeserver

4 posts in this topic

So i can query a timeserver using DAYTIME protocol

Local $recv, $sock, $cnt
if not TCPStartup() Then
    ConsoleWrite("TCPStartup() Error" &@cr)
    Exit
EndIf
$sock = TCPConnect(TCPNameToIP("ts1.univie.ac.at"), 13)
if $sock = -1 Then
    ConsoleWrite("TCPConnect() Error" &@cr)
    Exit
EndIf
While Not StringInStr($recv, @CR)
    $recv &= TCPRecv($sock, 64)
    $cnt += 1
    if $cnt > 2 Then
        Sleep (250)
    EndIf
    if $cnt > 15 Then
        ConsoleWrite("Connection Timeout" & @cr)
        ExitLoop
    EndIf
WEnd
ConsoleWrite($recv)
TCPCloseSocket($sock)
TCPShutdown()

the answer looks like 'Sat Oct 22 04:05:34 2005'

any sugestions about how to pass it to the os?

thanx in advance...


CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

RunWait(@ComSpec & " /c DATE " &$DateTimeDetails, "", @SW_HIDE) should help (you are passing parameters to the inbuilt DOS DATE function - do a similar thing for the TIME function). Try executing from the command line to see what format/order your particular locale needs the date/time in.

Good luck!

NB: Check out w32tm.exe with the /resync /nowait options to use the preconfigured time servers in Windows. See http://www.microsoft.com/technet/prodtechn...95d482db3a.mspx

Edited by Confuzzled

Share this post


Link to post
Share on other sites

This thing has to work on WinME to and Date has different formats depending on the country code (and i dont know how to optain it)...

but thanks anyway B)


CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Check out the _DateTimeFormat function in Date.au3 - one of the standard UDFs bundled with AutoIT3.

;===============================================================================
;
; Description: Returns the date in the PC's regional settings format.
; Parameter(s): $date - format "YYYY/MM/DD"
; $sType - :
; 0 - Display a date and/or time. If there is a date part, display it as a short date.
; If there is a time part, display it as a long time. If present, both parts are displayed.
; 1 - Display a date using the long date format specified in your computer's regional settings.
; 2 - Display a date using the short date format specified in your computer's regional settings.
; 3 - Display a time using the time format specified in your computer's regional settings.
; 4 - Display a time using the 24-hour format (hh:mm).
; Requirement(s): None
; Return Value(s): On Success - Returns date in proper format
; On Failure - 0 and Set
; @ERROR to: 1 - Invalid $sDate
; 2 - Invalid $sType
; Author(s): Jos van der Zande

; Note(s): None...
;
;===============================================================================

Edited by Jos

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0