Reputation: 1
I'm looking to print out the current time in a specified timezone in c. I understand that the time.h library has a few ways of displaying time but I can't figure out how to change those times depending on an inputted timezone. If anyone could point me in the right direction, I'd appreciate it.
Upvotes: 0
Views: 134
Reputation: 992797
Use the tzset()
function. Note that this sets the time zone globally for your whole process, since it reads from the TZ
environment variable (which is also process-global).
To change the TZ
environment variable, you can use putenv()
which takes a formatted environment variable in the form TZ=Europe/Paris
for example.
Upvotes: 2