Jump to content

Reading time from the internet


Recommended Posts

Ok I am stuck.

What I want to do sounds very simple but I think I a complicating it myself. All I want to do is get the current time and date from the internet and have it display in a MsgBox, I can not seem to figure out how to retrieve the information from on line. Example site " http://free.timeanddate.com/clock/i2dkat1s/n104/tt1/tw0/tm2/td1 ".

So like:

$ip = http://free.timeanddate.com/clock/i2dkat1s/n104/tt1/tw0/tm2/td1
$info =  ; command to check or retrieve time and date from $ip
MsbBox( 0, "Current Time and Date", "Current: " & $info)

Somthing like that I just dont know what command to use to accomplish this.

Please Help Thank You.

Link to comment
Share on other sites

I find it odd that you would want to get the time from the internet instead of your computer. This code should work for the link you posted though.

$ip = "http://free.timeanddate.com/clock/i2dkat1s/n104/tt1/tw0/tm2/td1"
$info = BinaryToString(InetRead($ip))
$aRegEx = StringRegExp($info, "(?s)<span id=t1>(.*?)</span>", 3)
MsgBox(0, "Current Time and Date", "Current: " & $aRegEx[0])
I have a script I use to set a trial period for a program the problem I have found is that when it compares the time written to reg key when the program was first ran to the computers time it works but if you set the computers time back it will make the program usable again. So I want to compare it to a time and date that they can not change. Make sense :x

Also Thank you very much works perfectly

Edited by Justforfun
Link to comment
Share on other sites

I have a script I use to set a trial period for a program the problem I have found is that when it compares the time written to reg key when the program was first ran to the computers time it works but if you set the computers time back it will make the program usable again. So I want to compare it to a time and date that they can not change. Make sense :x

Also Thank you very much works perfectly

Another one return "-1" if something fails

#include <String.au3>

;_Date(0) Success: A 0 based $Date[$ap] contains the first found string.

MsgBox(0, "", _Date(0))

Func _Date($ap)
    Local $Date
    If InetGet("http://free.timeanddate.com/clock/i2dkat1s/n104/tt1/tw0/tm2/td1", @TempDir & "\~data.tmp") Then
        $Date = FileRead(@TempDir & "\~data.tmp")
        $Date = _StringBetween($Date, "<span id=t1>", "</span>", -1)
        FileDelete(@TempDir & "\~data.tmp")
        If $ap < UBound($Date) Then Return $Date[$ap]
    EndIf
    Return SetError(1, 0, -1)
EndFunc   ;==>_Date

Regards

.

Link to comment
Share on other sites

It makes a bit more sense now. Couldn't they just change the registry key though or do you have the key encrypted?

I am using _StringEncrypt command to encrypt the reg key. Thanks for asking though just incase I didnt encrypt it.

Edited by Justforfun
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...