Search code examples
c++timetrialware

How to retrieve time from the internet (bypassing PC clock)?


For my MFC/C++ unmanaged time-limited software needs, I'd like to get a GMT/UTC time-stamp from the internet (instead of relying on the PC clock time that can be easily changed).

I already though about parsing the line "Current UTC"... line from http://www.timeanddate.com/worldclock/ (I think port 80 is more likely to be open than others) but I don't know how reliable this URL is...

Please share with me your pros/cons or different ideas on this.


Solution

  • Looks feasible and this is widely done.

    Scraping of timeanddate.com can break if the site decides to change its HTML. Even a slight change in the HTML can break your scraper.

    I would suggest you use a web service like earthtools. You'll have to pass the necessary arguments(latitude and longitude etc) in the URL and the response is XML which you can easily parse.