I have used sntp example from esp idf and modified it as per my use as folllows-->>>
Code: Select all
void sntp_task(void *pvParameter) {
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0,"asia.pool.ntp.org");
sntp_init();
time_t now;
struct tm timeinfo;
struct tm *tmp;
time(&now);
localtime_r(&now, &timeinfo);
while(timeinfo.tm_year < (2019 - 1900))
{
printf("Time not set, trying...\n");
vTaskDelay(5000 / portTICK_PERIOD_MS);
time(&now);
localtime_r(&now, &timeinfo);
}
while(1)
{
time(&now);
setenv("TZ", "UTC-5:30", 1);
tzset();
tmp = localtime( &now );
strftime(Timebuffer, sizeof(Timebuffer), "%d/%m/%Y %I:%M:%S %p", tmp);
vTaskDelay(999 / portTICK_RATE_MS);
}
}
Don't know what is the problem.
please help me out to solve this.