Jump to content
Sign in to follow this  
mark2004

Get foolproof time stamp

Recommended Posts

mark2004

I am trying to write a timeclock program for my business where employees click a button

to clock in and out. If I use the time/date macros built into Autoit am I just pulling this from

the system time?? If so, it seems that it would be pretty easy to just change the system time

and then clock in/out and then change the system time back to normal and fool the system.

My question is: Is there a way to get time values that are independent of the Windows system

time (the time that is adjustable from the system tray)????

Thanks.

Share this post


Link to post
Share on other sites
Valuater

This might help..

MsgBox(4096, "Time", GetTime())

Func GetTime()
    $getlist = InetGet("http://tycho.usno.navy.mil/cgi-bin/timer.pl", "c:\time")
    If $getlist = 0 Then MsgBox(0, "Error", "Inet time not availible, check connection.")
    $infile = FileRead("C:\time", FileGetSize("C:\time"))
    $mytime = StringInStr($infile, "UTC")
    $thetime = StringMid($infile, $mytime - 9, 8)
    $hour = Number(StringLeft($thetime, 2))
    $min = Number(StringMid($thetime, 4, 2))
    $sec = Number(StringRight($thetime, 2))
    Return $hour & ":" & $min & ":" & $sec
EndFunc   ;==>GetTime

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
mark2004

This might help..

MsgBox(4096, "Time", GetTime())

Func GetTime()
    $getlist = InetGet("http://tycho.usno.navy.mil/cgi-bin/timer.pl", "c:\time")
    If $getlist = 0 Then MsgBox(0, "Error", "Inet time not availible, check connection.")
    $infile = FileRead("C:\time", FileGetSize("C:\time"))
    $mytime = StringInStr($infile, "UTC")
    $thetime = StringMid($infile, $mytime - 9, 8)
    $hour = Number(StringLeft($thetime, 2))
    $min = Number(StringMid($thetime, 4, 2))
    $sec = Number(StringRight($thetime, 2))
    Return $hour & ":" & $min & ":" & $sec
EndFunc   ;==>GetTime

8)

Thanks. Also, is there a way to get access to any other stable time source without using the

internet?? I currently have a PC in my shop that is off the network and I'd like to be able to

use a PC timeclock until I can get internet out there.

Share this post


Link to post
Share on other sites
Spiff59

That's a cool website. Gives you the time without a ton of HTMl to wade through.

I have a script that stamps transactions with the time, and will make use of that routine to correct the system clock.

I did change it a bit to get rid of the disk access (and I want to keep the leading zeros):

include<inet.au3>

MsgBox(4096, "Time", GetTime())

Func GetTime()
    $infile = _InetGetSource("http://tycho.usno.navy.mil/cgi-bin/timer.pl")
    If $infile Then Return StringMid($infile, StringInStr($infile, "UTC") - 9, 8)
    MsgBox(0, "Error", "Inet time not availible, check connection.")
EndFunc;==>GetTime

Edit: Actually, I'll do the search on "Central - 17" so I wont have to do the "$hour -= 6; If $hour < 0 then $hour += 24" thing to convert GMT to my time zone

Edited by Spiff59

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.