how to get the real current date?

[quote=42613:@Michel Bujardet]A web app should have accurate time, as it executes on a host that is usually synchronized over the Internet.

I have a web app for customers to download during a given period of time. Upon sale I create a file where I record the customer details, and TotalSeconds. Then all I have to do is compare with current TotalSeconds, each day represents 86400 seconds. An I do not have to compare “real time”…[/quote]

I can control the time of my server as I wish. If a demo app only checks upon startup even better, as I can change it back afterwards. I can also create a new instance only for a demo app that has its own time always and resets it back every time the app quits. Or every day, as I wish.

Your assumption is as flawed as thinking a user won’t change his internal clock, in the sense that while it’s true, it’s easy to work around.

If we assume a web app runs on a server that has internet access, trying to synchronize against an internet server makes sense, if checking against the local time works. Checking against a saved file or internally adding run time and then comparing that between starts for discrepancies also work pretty well.

Eduo

Yeah, right. It’s easy. That helps a lot.

Another alternative is to retrieve the contents of http://www.timeapi.org/utc/now using httpsocket and parse.

That doesn’t mean they are correct. When I installed Windows 8, although it had the correct time, it had the wrong time zone, so that really means the wrong time. And it was set to use internet time. Even worse, finding the ability to change the time required a Google search, and of course the desire to fix it.

Real Studio’s activation system required the computer’s clock to be set correctly. 90% of the time, the users who had problems were on Windows. Windows is very, very bad about having the clock set correctly, even when using internet time.

Sarcasm aside (both on this and in the edited comment) we’re developers talking about the programs we develop. When we talk about “demo mode” (as the OP did in the message you replied to and to which I replied in turn) we talk about the demo period an application can run without having to pay for it. It’s irrelevant if the application is a desktop or web application, when distributed and run in local systems it reads the local clock.

If what you’re talking about is people running your apps in your server then, obviously, that’s not what everyone else in the thread is talking about since, obviously as well, you have control over your own system (which was my point to begin with).

While this works for rough time it’s rounded to the nearest second on the remote end. It doesn’t work if you need accuracy and especially if you need to sync systems in different locations down to the tenth of the second.

[quote=42567:@Neil McAliece]There is some php code on the following URL which does the more accurate request, you would need to port it over to Xojo :

It needs modifying slightly to get it working due to the cookie stuff they use but when I tested it I got an output accurate to 1/10,000th of a second like this :

NTP time: 2013-10-25 22:27:11.7583

http://xlo.co/blog/general/php-ntp-client

There’s a lot more to NTP that you might think - it takes into account the round trip of the network request instead of just issueing a single time so it sends back a bunch of bytes which need interpreting correctly.

More info here : http://www.kloth.net/software/timesrv1.php

[/quote]

I’m interested in this. I’ll take a look at it and see about either porting to Xojo or setting a master sync server and doing it all there.

enough. Game over. You got the last word, master.

I’m sorry but I have no clue what you’re implying here. What last word? “Master”?

the ntp example is good for me

and the example code have to change to

apple’s time +(localtime2-localtime1)/2

I can confirm that. :frowning:

[quote=28561:@Greg O’Lone]Forgive me if this code is a mess… I wrote it eons ago :slight_smile:

NTP Example[/quote]

@Greg O’Lone can you please repost a link to this code example??? :slight_smile:

Sure! NTP Example

@Greg O’Lone Thank you sir. :slight_smile: