Sign in to follow this  
Followers 0
Justforfun

Reading time from the internet

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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

.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

It just occurred to me that they could just delete the whole key and get a new one. Do you have a system to prevent that?

Um nope but it would be a bit of a challenge to find because it is not named after the program

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  
Followers 0