1
I am developing a program in C# that allows a click at a certain time chosen by the user. For now the program clicks subtracting the time chosen by the user with the local time, but I discovered a little while ago that through the Headers of a website you can know the exact time of the server, which would make it easier for me because the program is being developed to work based on the time of the same.
I use these lines of code to get the Headers of the website:
var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("https://www.exemplo.com.pt/");
var response = myHttpWebRequest.GetResponse();
To subtract the time entered by the user and the local time I use this line of code:
TimeSpan wait_time = objetivo.Subtract(DateTime.Now); //'objetivo' = hora inserida pelo utilizador
My question is, how can I just pick up the date at Headers from the website and then subtract from the time chosen by the user?
Thank you so much Renan! It really worked returning something like
19-04-2017 15:30:35
. Is there any way to know the Milliseconds either, or the Header Date only returns Hours, Minutes and Seconds?– Bruno
Unfortunately, as far as I know, that header only goes up to the second.
– Oralista de Sistemas