Jump to content

Get foolproof time stamp


Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...