Hi, do we have a way to get NTP localtime without a manual configuration?
I mean with the callling IP, a geolocation can be done and out of that the time zone parameters TZ and DST_MN automatically derived, isn't it?
Getting NTP localtime without config?
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Getting NTP localtime without config?
Geolocation is a service provided by a 3rd party. Those services are generally not free (as in the GPL definition of free). They are free (as in beer), from many sites after a registration. Here's an example
My preference nowadays is to get the timezone and utc from a web client through a hidden element in a form. It's been on my list to make a demo of that. I'll post an example here when I extract that from a larger project (and convert it to arduino).
My preference nowadays is to get the timezone and utc from a web client through a hidden element in a form. It's been on my list to make a demo of that. I'll post an example here when I extract that from a larger project (and convert it to arduino).
Re: Getting NTP localtime without config?
Thank you!lbernstone wrote: ↑Tue Jul 16, 2024 5:48 pmGeolocation is a service provided by a 3rd party. Those services are generally not free (as in the GPL definition of free). They are free (as in beer), from many sites after a registration. Here's an example
My preference nowadays is to get the timezone and utc from a web client through a hidden element in a form. It's been on my list to make a demo of that. I'll post an example here when I extract that from a larger project (and convert it to arduino).
That's a lot of stuff to just derive one's TZ and DST_MN.
In fact, I can get from another site my current timezone in a verbose form. e.g.: "Europe/Berlin".
Is it easier to get TZ and DST_MN from that?
Or have we got a way to call NTP with this info instead of TZ and DST_MN?
Regards
Laszlo
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Getting NTP localtime without config?
Last edited by lbernstone on Thu Jul 18, 2024 4:48 pm, edited 1 time in total.
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Getting NTP localtime without config?
NTP uses UTC time. Always. Period.
The timezone can be set manually by calling
The strings that are recognized are compiled in the crossNG toolchain. I am pretty certain that all the ST/DT strings in my zones file are recognized. The city name strings may or may not be.
The timezone can be set manually by calling
Code: Select all
char tz[] = "HST10";
setenv("TZ", tz, 1);
tzset();
Re: Getting NTP localtime without config?
Sure. We are speaking about about the ESP library, which needs TZ and DST values to get the local time.
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Getting NTP localtime without config?
Very intelligent post...
Who is online
Users browsing this forum: No registered users and 23 guests