![]() |
find timezone using C
how to know the timezone using C ...
i want something which will work both on Linux and Windows... for example in case of India...i wish to know using the program that the timezone is GMT+ 5:30 i found a variable called _timezone which works in case of Windows but not on Linux. |
Re: find timezone using C
http://www.hmug.org/man/3/strftime.php
http://www.hmug.org/man/3/ctime.php gmtime(), localtime(), strftime() would seem to be functions worth a look. |
Re: find timezone using C
i have tried all the above functions...but what i need is to print the current time in the undermentioned format:
Tue Jan 08 2008 22:25:22 GMT+0530 (India Standard Time) i am able to print everything except GMT+530 using the function strftime... so i am looking for some variable or function which can tell me the current timezone.. and i have to find the solution only within the ANSI/C89 boundaries..the functions like localtime must be using something to chge the time from UTC to localtime.. |
Re: find timezone using C
So what does this produce for you?
Code:
#include <stdio.h> |
Re: find timezone using C
This is the output i get..instead of the time difference in number...i get India Standard Time twice...!!
>>Wed Jan 09 2008 India Standard TimeIndia Standard Time<< as I stated earlier ..i need GMT+0530.. for the time being what i am doing is ..subtracting the value of localtime and gmtime.. hence i get the time difference in seconds..(which comes out to be 19800 seconds in case of India) ...so i calculate number of hours from it and concatenate it to my output string... but i still need a way out of calculating the time difference... |
Re: find timezone using C
this is something what i have tried and is now giving the right output...
still looking for an easy way out :D :) Code:
#include <stdio.h> |
Re: find timezone using C
ignore the indentation in the last post...
it messed while copying the code from Visual Studio editor to explorer.. :) |
| All times are GMT +5.5. The time now is 21:53. |