I am working on an Linux based router. I am working on a C application. I want to get current time in my application continuously.
The problem is, it gives me time according to the application launch timezone although I have changed timezone after the application started. The timezone of the system has been changed. The date
command on Linux terminal shows different timezone and date/time.
time_t currTm;
struct tm *loctime;
char udrTime[50];
while (1)
{
currTm = time(NULL);
loctime = localtime(&currTm);
strftime(udrTime, sizeof(udrTime), "%Y-%m-%d %H:%M:%S", loctime);
printf("udr_time = %s\n", udrTime);
usleep(10000);
}
I expect output according to timezone changes.