Here i have attached piece of code which i have used to get the real world time but the time i am getting is base time which is shown as output below
how to get the current time
Input :
#inlcude<time.h>
time_t now;
char strftime_buf[64];
struct tm timeinfo;
time(&now);
// Set timezone to India Standard Time
setenv("TZ", "UTC-5:30", 1);
tzset();
localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
ESP_LOGI(TAG, "The current date/time in India is: %s", strftime_buf);
Output :
I (05:30:28.084)example.c: The current date/time in India is: Thu Jan 1 05:30:28 1970
How to fetch real world time using NTP server, I am getting root time ie. 1 jan,1970
-
- Posts: 44
- Joined: Fri May 13, 2022 12:36 pm
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
-
- Posts: 44
- Joined: Fri May 13, 2022 12:36 pm
Re: How to fetch real world time using NTP server, I am getting root time ie. 1 jan,1970
Thanks for the suggestion
got the solutions
regards.
got the solutions
regards.
Who is online
Users browsing this forum: Baidu [Spider] and 94 guests