Jump to content

Obtaining a Timestamp from a website/server


Recommended Posts

I was wondering if anyone knows a way for in which when I begin to run my script, it could obtain a current date timestamp from a server or website, particularly my website?

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Hi Realm

Using trancexx UDF

And Working Example:(see below)

P.S You need place WinHTTP.au3 in same folder with this example.

It works for me and OutPut for me:

Posted Image

#include "WinHTTP.au3"
$nOffset = 1

$input=InputBox("Enter Site URL","ENTER SITE URL","","")
$hOpen = _WinHttpOpen()

$hConnect = _WinHttpConnect($hOpen, $input)

$hRequest = _WinHttpOpenRequest($hConnect, "GET", "/")

_WinHttpSendRequest($hRequest)

_WinHttpReceiveResponse($hRequest)

If _WinHttpQueryDataAvailable($hRequest) Then
    $header = _WinHttpQueryHeaders($hRequest)

_WinHttpCloseHandle($hRequest)

_WinHttpCloseHandle($hConnect)

_WinHttpCloseHandle($hOpen)


FileWrite(@TempDir&"\headerinfo.txt",$header)

 EndIf


$str=FileRead(@TempDir&"\headerinfo.txt")

While 1
    $array = StringRegExp($str, '(?i)Date: (.*?)(?i)GMT', 1, $nOffset)

    If @error = 0 Then
    $nOffset = @extended
    Else
    ExitLoop
    EndIf
    for $i = 0 to UBound($array) - 1
    msgbox(0, "DATE:", $array[$i],10)
        FileDelete(@TempDir&"\headerinfo.txt")
    Next

WEnd
Edited by Fire
[size="5"] [/size]
Link to comment
Share on other sites

Fire, Thanks for reply, that is a perfect example for what I need, and also thanks for pointing out trancexx's UDF I see alot of future uses with that as well.

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

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...