How can i get internet date with C++?

Hello guys i have seen a lot posts around the web everyone giving different answers i know there is a lot of ways but i still cant find any good one working for me i am using visual studio 2012 for C++ . Can any one please write me a small working snippet code to get the date & time from the web like in this post:

http://stackoverflow.com/questions/22403892/how-to-check-the-real-date-through-an-internet-connection

A guy gives an answer on the post above but no code also the code in this post down here looks great but its in c# have no idea were to start from!!!!

https://nickstips.wordpress.com/2010/02/12/c-get-nist-internet-time/

The only thing that nobody is writing a small working snippet code in c++

i really don't need any license manager we are not talking of a code that would value a lot its just for safety to prevent normal good people to keep staying good.

I hope i am more clear!!! let me know and thanks in advance

The best way is to not do it. Ensure that the host computer is updating its clock periodically and then get the time from the host. Don't be That Guy who bombards NIST's computers every millisecond for no good reason.

Besides, consider the error conditions. time_t now=time(0) will basically never fail. If you get it from the internet then it's quite likely that the call will fail. What will you do then?
Well i didnt ask to get the time just simply the date also what you mean time(0) will never fail if i am talking about the date and would check only once get open the program i would bombard and check every second lol!!!but the idea of the host seems nice how can i get that?
I would like to check the date from it is it possible if yes how? can you give me any good exmples? thanks man for answering!!!
If you had read the manual you would have known that time() returns the number of seconds since the Epoch, which is obviously convertible to a date.

@dhayden's suggestion:
1
2
3
4
5
6
#include <iostream>
#include <ctime>
int main() {
  std::time_t const result = std::time(nullptr);
  std::cout << std::asctime(std::localtime(& result));
}
Topic archived. No new replies allowed.