datkewlguy Posted April 13, 2005 Share Posted April 13, 2005 Hello, just wondering if anyone knew of any good ways to return the actual date, instead of the one on your computer. Link to comment Share on other sites More sharing options...
Westi Posted April 13, 2005 Share Posted April 13, 2005 MESZU.S TimeGMT Link to comment Share on other sites More sharing options...
datkewlguy Posted April 13, 2005 Author Share Posted April 13, 2005 Well that is okay, but i really need to return this info and have it used in a script and that is where i am stuck Link to comment Share on other sites More sharing options...
steveR Posted April 13, 2005 Share Posted April 13, 2005 (edited) I been looking for a cmd line utility to return a time, but haven't had much luck. I was thinking along the lines of: net time \\time.nist.gov But that doesn't work. Edited April 13, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
datkewlguy Posted April 13, 2005 Author Share Posted April 13, 2005 hmm, i cant get it to work either, the params are this though if anyone else can figure it out... ================================== NET TIME \\computername | /DOMAIN[:domainname] | /RTSDOMAIN[:domainname]] [/sET] [\\computername] /QUERYSNTP [\\computername] /SETSNTP[:ntp server list] ================================== If anyone can figure this out for me it'd be very useful Link to comment Share on other sites More sharing options...
Smed Posted April 14, 2005 Share Posted April 14, 2005 Even though the docs for NET TIME say it should do the trick, it doesn't. Not sure why. This does work though:Create W32Time.ini in the @WINDOWS folder that contains the following:[W32Time]Type=NTPLog=yesPeriod=0TASync=noNTPServer=pool.ntp.orgLocalNTP=noThen start (or restart) the "Windows Time" service... watch your time change.If you need command line...NET START W32TimeFor the gory details, see W32Time Network Time Service (from MS)And a list of regional Public NTP Servers/disclaimer, works for me under Win2000, mileage may vary on other platforms. 601DisengageEnd Program Link to comment Share on other sites More sharing options...
steveR Posted April 14, 2005 Share Posted April 14, 2005 (edited) Will this redirect to stdout? That's what we are looking for. A string or integer or something returned that can be parsed to be used in a script. Here is an excerpt from the protocol. If we could get a hold of the UTC number. Network Time Protocol (RFC-1305) The Network Time Protocol (NTP) is the most commonly used Internet time protocol, and the one that provides the best performance. Large computers and workstations often include NTP software with their operating systems. The client software runs continuously as a background task that periodically gets updates from one or more servers. The client software ignores responses from servers that appear to be sending the wrong time, and averages the results from those that appear to be correct. Many of the available NTP software clients for personal computers dont do any averaging at all. Instead, they make a single timing request to a signal server (just like a Daytime or Time client) and then use this information to set their computers clock. The proper name for this type of client is SNTP (Simple Network Time Protocol). The NIST servers listen for a NTP request on port 123, and respond by sending a udp/ip data packet in the NTP format. The data packet includes a 64-bit timestamp containing the time in UTC seconds since January 1, 1900 with a resolution of 200 ps. Edited April 14, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
Smed Posted April 14, 2005 Share Posted April 14, 2005 (edited) dos command, time /tEDIT: ah, I see the the object was to Determine the correct time, not to Correct the time... so sorry.EDIT2:Ok, here's the low-down:w32tm -once -testIt produces a crap-load of output but does give the info you want w/o changing the local clock. (-once for only query the server once, and -test for don't set my clock) It appears that you can't choose the server from command line however. I turned off my time service, renamed the W32Time.ini file, AND rebooted, but it had saved the time server in the registry under HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters ntpserverI hope that helps EDIT3:And guess what! NET TIME /setsntp:xxxx changes that registry entry if you don't want to go monkeying around with finding the correct entry to change. EDIT4:The line that is consistently there no matter how far the clock is off is the one that says "ClockError", value is in ms Edited April 14, 2005 by Smed 601DisengageEnd Program Link to comment Share on other sites More sharing options...
jdickens Posted April 14, 2005 Share Posted April 14, 2005 I believe there is useful info on this recent thread, courtesy of RocTx.http://www.autoitscript.com/forum/index.php?showtopic=10278J If I am too verbose, just say so. You don't need to run on and on. Link to comment Share on other sites More sharing options...
steveR Posted April 14, 2005 Share Posted April 14, 2005 w32tm -once -testGlad you figured something out. Unfortunatly, those switches aren't supported on xp/nt. AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
datkewlguy Posted April 14, 2005 Author Share Posted April 14, 2005 Well i still can't figure things out, What im working on is an expiration program and having it not work after a certain date... but it is weak if it can be removed simply by changing your date. I just need to aquire a date from the internet and have the script recognize that as the date, or correct the date to that. Link to comment Share on other sites More sharing options...
datkewlguy Posted April 15, 2005 Author Share Posted April 15, 2005 I take it no one knows... I've gotten pretty close but the best i can do is return the time from a networked computer... Link to comment Share on other sites More sharing options...
Smed Posted April 15, 2005 Share Posted April 15, 2005 Glad you figured something out. Unfortunatly, those switches aren't supported on xp/nt. <{POST_SNAPBACK}>works great under W2K, try adding the -v option if you're getting no output. haven't tested with XP yet. 601DisengageEnd Program Link to comment Share on other sites More sharing options...
CyberSlug Posted April 15, 2005 Share Posted April 15, 2005 (edited) *Might* work. More than likely contains bugs $tempFile = "temp.txt" InetGet("http://www.whattimeisit.com/", $tempFile, 1) $text = FileRead($tempFile, FileGetSize($tempFile)) $start = StringInStr($text, "<B>") $stop = StringInStr($text, "</B>") $text = StringMid($text, $start+3, $stop-$start-3) $text = StringReplace($text, "<BR>", "") $text = StringSplit($text, @LF) $date = StringStripWS($text[1], 3);date in the form Month, D YYYY $time = StringStripWS($text[2], 3);time in the form hh:mm:ss PM If StringInStr($time, "PM") Then $time = Number($time) + 12 & ":" & StringTrimRight($time, 3) $time = StringTrimRight($time, 3) $start = StringInStr($date, ",") $stop = StringInStr($date, " ", 1, -1) $month = StringLeft($date, $start-1) $day = StringMid($date, $start+2, $stop-$start-2) If StringLen($day) = 1 Then $day = "0" & $day $year = StringMid($date, $stop+1) $month = StringInStr(" January February March April May June July August September October November December", $month)/10 MsgBox(4096,"", $year & "/" & $month & "/" & $day & " " & $time) ; Optionally delete the file: ;FileDelete($tempFile) Edited April 15, 2005 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
datkewlguy Posted April 15, 2005 Author Share Posted April 15, 2005 actually that was about perfect, i made some tiny changes barely noticable though, now my result is in the wrong timezone too fast, how can i make this read the US Eastern Time? $tempFile = "temp.txt" InetGet("http://www.whattimeisit.com/", $tempFile, 1) $text = FileRead($tempFile, FileGetSize($tempFile)) $start = StringInStr($text, "<B>") $stop = StringInStr($text, "</B>") $text = StringMid($text, $start+3, $stop-$start-3) $text = StringReplace($text, "<BR>", "") $text = StringSplit($text, @LF) $date = StringStripWS($text[1], 3);date in the form Month, D YYYY $time = StringStripWS($text[2], 3);time in the form hh:mm:ss PM If StringInStr($time, "PM") Then $time = Number($time) + 12 & ":" & StringTrimRight($time, 3) $time = StringTrimRight($time, 3) $start = StringInStr($date, ",") $stop = StringInStr($date, " ", 1, -1) $month = StringLeft($date, $start-1) $day = StringMid($date, $start+2, $stop-$start-2) If StringLen($day) = 1 Then $day = "0" & $day $year = StringMid($date, $stop+1) $month = StringInStr(" January February March April May June July August September October November December", $month)/10 ; Optionally delete the file: FileDelete($tempFile) MsgBox(4096,"", $month & "/" & $day & "/" & $year & " ");& $time Link to comment Share on other sites More sharing options...
CyberSlug Posted April 15, 2005 Share Posted April 15, 2005 Parse the temp file yourself StringInStr($text, "US/Eastern Time") then count the number of characters or look for markers such as "</td>" tags.... Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
datkewlguy Posted April 15, 2005 Author Share Posted April 15, 2005 k thanks again 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