Simple way to get date from Internet time server?

In my searching, several posts came up but many have links to examples that are not available and it sounds like it’s somewhat complicated.

Is this doable in Xojo or is a plugin needed?

I just want to make sure that the computer’s date is the same as a trusted time server.

Suggestions?

I’ve got a class here for doing this. Not sure where it came from but I just checked it and it works here on my Mac.

https://www.dropbox.com/scl/fi/q7ozx64qa5sfwd1oddkwm/ntp.xojo_binary_project?rlkey=wmcy42av8vgpff66cmzvlhpz2&dl=1

1 Like

Thanks Greg! Worked on my Mac as well. I’ll test on Windows and Linux. This should work for my purposes.

Well unfortunately, it only seems to work on the Mac. I tried with Windows 10 and Linux and it didn’t work. :frowning:

It works here on those platforms. You’ll need to make sure you don’t have anything blocking UDP port 123.

Darn…I don’t have anything special setup on the Windows or Linux Boxes that should be blocking anything. It works with the Mac on the same network so don’t see the issue being there. I tried it with a Windows 11 VM on the Mac and it doesn’t work there either.

I’m hoping there is another way to do this. Since getting the time from the internet is something most systems do these days, there has to be a way to great the date and time from one of the servers without worrying about ports.

Did you try the Apple time server on windows & Linux? The demo chooses one that’s specific to each platform, but I tend to use time.apple.com for everything.

I did try the apple server as well as some other published time servers, still only works on the Mac for me.

Works perfectly fine on Windows. (all listed time servers)

2 Likes

Strange…however since it doesn’t work on 2 of the 3 for me, I think it’s safe to say others may have issues too regardless of the cause.

I’m looking at other options.

Steve

Sounds like you may be doing this to prevent someone from setting their clock back so they can continue using a software application?

If so, I have a suggestion for you.

1 Like

Not here. Win 11. Never works. All options. All them return the following:

image

1 Like

Yes, I need the time date to be valid

That’s what I get too.

1 Like

Some potential bread crumbs.

Digging through search results on DuckDuckGo makes it look like this could be a Windows 11 Firewall or an ISP or a router issue related to certain ports (more likely UDP??) being blocked.

@Steve_Batson if you’re having success with a Mac but not with a Windows 11 PC on the same network, then it’s probably not your ISP or router…

1 Like

Agreed

Would a simple GET from http://worldtimeapi.org/api/timezone/etc/utc suffice?

1 Like

That could work. I’ll check it out

This address is very frequented. So be prepared to make several queries in a row, if necessary, until it works. :wink:

Yesterday it was simply unreachable from my end, today it’s working. (worldtimeapi.org)

From the FAQ:

image