Jump to content
Sign in to follow this  
Foxhound

Sync System Time With NIST

Recommended Posts

Foxhound

Here's a little snippet to quickly sync your system clock with that of NIST.

#cs---------------
 Sync Time
 By Foxhound

 Public Domain
#ce --------------
#RequireAdmin

_set_time(_get_time())

Func _get_time()
 $central = "http://nist.time.gov/timezone.cgi?Central/d/-6"
 $eastern = "http://nist.time.gov/timezone.cgi?Eastern/d/-5"
 $data = BinaryToString(InetRead($central))
 $regex = "\d{1,2}:\d{1,2}:\d{1,2}"
 $match = StringRegExp($data, $regex, 3)
 if not IsArray($match) Then return false
 Return $match[1]
EndFunc   ;==>_get_time

Func _set_time($time)
  if NOT $time Then Exit

 RunWait(@ComSpec & " /c " & 'time ' & $time, "", @SW_HIDE)
EndFunc   ;==>_set_time

EDIT:

Uhhh... why is the forum injecting BBCode into my post? Someone should get to work fixing that :S

Edited by Foxhound
  • Like 1

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  

×