Get time not depending on system time

I am trying to check the current time, but not depending on the system’s time, i.e. if user changes computer’s time it won’t have any effect on the retrived time. Has anyone faced this in OF/C++?

I might have to get that information from a Server, does anyone know how I would go about that?

So you want to be able to get the world time rather than whatever time the clock is set to on a computer? Yeah like you said, you are going to have to read that information from a server.

I’d google around for a service that fits your needs. How many times do you need to be able to check the world time a day? There are free APIs out there that just require you to register to get an API key. Here’s one. It spits back an xml file, which you can parse in openFrameworks. (That linked xml file has a throw-away API key in it, so you’d need to get your own.)

Your code would look something like this to get the xml file from the url:

string url = "http://api.timezonedb.com/?zone=Australia/Melbourne&key=56B28IQYZKPI";
ofHttpResponse response = ofLoadURL(url);
ofxXmlSettings xml;
xml.loadFromBuffer(response.data);

Then you’d parse the xml file like the examples listed on the ofxXmlSettings page.

Hi @mikewesthad, thaks a lot for the reply. I knew there was an easy way :slight_smile: