Results 1 to 2 of 2
Hello: From a C program, how do I convert to local time when the TZ environment variable is set to UTC. (We want to keep our system in UTC, and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-19-2012 #1
- Join Date
- Oct 2006
localtime() for a different timezone
From a C program, how do I convert to local time when the TZ environment variable is set to UTC. (We want to keep our system in UTC, and only use local time in this instance.).
I can do:
from the command line and get the proper result. I don't want to call use a system system("TZ=EST date") call from my C program fearing it will be too slow. And I want to avoid calculating time myself.
I have seen others setenv() to set the TZ environment variable from userspace then unsetenv() however, I worry that other processes (threads,etc) could ask for time when this is set to the local TZ.
- 12-28-2012 #2
- Join Date
- Sep 2004
Hav'nt got time to try and verify it but have a look at man pages for setenv and tzset (eg. set the TZ variable to something using setenv() and then call tzset() before calling localtime()).In a world without walls and fences, who needs Windows and Gates?